1
votes

Here's my dataset

Column 1: Lipid level

Column 2: Age

Column 3: Fat content category

Column 4: Gender (1=male)

   0.73      1      1   1
   0.67      1      2   1
   0.15      1      3   1
   0.86      2      1   1
   0.67      2      2   1
   0.15      2      3   1
   0.94      3      1   1
   0.81      3      2   1
   0.26      3      3   1
   0.23      4      1   2
   1.40      4      1   1
   1.32      4      2   1
   0.15      4      3   1
   1.62      5      1   1
   1.41      5      2   1
   0.78      5      3   1
   9.78      5      1   1

Here's a few different analysis I'm running with this code but I'm not so sure why SAS is not compiling.

Before doing anything else, I set up a permanent library manually.

libname di ‘c:\diet’;
data di.HW3 Data;
infile hw3 data.sas;
input Lipidlevel Age Fatcontent Gender;
run;

Is there any way that I can stratify the data as follows? I want to create labels and formats for both the Age Group and Fat Content Category variables. The age groups are coded 1 to 5 and correspond to: 15-24; 25-34; 35-44; 45-54; 55-64. The fat content categories are coded 1 to 3 and correspond to: extremely low; fairly low; moderately low. I have no idea how to do this. The only way I can think of is to go into the original dataset and sort them out manually.

I mean of course if I were given a much larger dataset then it would be impractical to do so. Can I get some help here?

1
Your INFILE statement is wrong. Either include a fileref (ie alias) like hw3 or a physical path like "data.sas", but not both. Also watch out for those not quote character quotes that WORD or something has generated in your libname statement. SAS does not understand those fancy quotes. Just normal " or ' quotes. - Tom
Are you asking how to create formats for your coded variables (what SPSS would call value labels)? Use PROC FORMAT to create them. You can then use a FORMAT statement to tell SAS which formats to use with which variables. - Tom

1 Answers

1
votes

To have your coded variables display with descriptive words you should use formats. First define some formats.

proc format;
  value agegp 1='15-24' 2='25-34' 3='35-44' 4='45-54' 5='55-64';
  value fat   1='extremely low' 2='fairly low' 3='moderately low';
  vale sex '1'='male' ;
run;

You can then attach them to the variables. You can do it in the step that creates the dataset, or just attach them where you want to use them.

proc freq data=di.hw3;
  tables age fatcontent gender;
  format age agegp. fatcontent fat. gender sex. ;
run;