BookmarkSubscribeRSS Feed
u49589061
Fluorite | Level 6

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. 

 

 

Screen Shot 2021-04-14 at 4.03.48 AM.png

 

13 REPLIES 13
japelin
Rhodochrosite | Level 12

What is raw data?

u49589061
Fluorite | Level 6

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.

japelin
Rhodochrosite | Level 12

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.

u49589061
Fluorite | Level 6

Please let me know if this works.

Kurt_Bremser
Super User

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, ...)?

u49589061
Fluorite | Level 6
 
japelin
Rhodochrosite | Level 12

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;

 

 

u49589061
Fluorite | Level 6

I want to construct the data table in the photo below, but I don't know how to in sas

Screen Shot 2021-04-14 at 5.30.36 AM.png

japelin
Rhodochrosite | Level 12

@Kurt_Bremser This is probably stata data, which I could import with a simple import procedure.

proc import file="\projectdata020719.dta" out=have;
run;

2021-04-14_20h14_43.png

 

u49589061
Fluorite | Level 6
I know the basic processing of sas. I just don't know how to put get multiple subcategories in the first row of my table so that I can properly label my observations.
Kurt_Bremser
Super User

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).

japelin
Rhodochrosite | Level 12

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; 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 13 replies
  • 1476 views
  • 2 likes
  • 3 in conversation