Hi everyone, I'm struggling to construct the three data tables below and I would really appreciate it if someone could help me. The variables highlighted in yellow are the ones listed in the data set. I also attached the data dictionary to this post.
What is raw data?
I am unable to attach the original data set to this post because the file size is too big. But the variables in the raw data set are highlighted in yellow.
Please provide just some observations.
For example, a dataset of 10obs can be created as follows
data sample;
set have(obs=10);
run;
You can also use datalines to describe the sample data.
Please let me know if this works.
From where do you get the data (so we might be able to download an example ourselves)?
In which form do you get it (CSV or other text format, transport file, ...)?
So what exactly do you want to do with this data?
Are you having trouble importing the data? Or converting it?
If you simply want to extract the variables, you can do that with the following...
data want;
set have;
keep AGEATINTERVIEW GENDER MARITALSTATUS;/* and other variables */
run;
I want to construct the data table in the photo below, but I don't know how to in sas
The .dta file is some kind of binary data file. From which application does it originate?
@Kurt_Bremser This is probably stata data, which I could import with a simple import procedure.
proc import file="\projectdata020719.dta" out=have;
run;
The yellow cells in your Excel match the variable names in the dataset, so all you need is a KEEP statement.
If you need more than that, show an example of the "want" dataset(s).
I created this sample program thinking that you simply want to divide the data into three data sets.
Can you show me an image of the finished product, even in Excel? (Variable name in the first line, data in the second and subsequent lines)
proc import file=".\projectdata020719.dta"
out=have;
run;
data DM;
set have;
keep seqn ageatinterview gender maritalstatus education householdincome;
run;
data RF(label='Risk factors and Medical fix');
set have;
keep seqn SMOKENOW EVERSMK100CIGS HICHOL_HX;
;
run;
data CP(label='Clinical presentation');
set have;
keep seqn BPXSAR BMI MORTSTAT DIABETES_HX LIVER_HX THYROID_HX AVE_DAILY_PA;
where AVE_DAILY_PA=1;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.