I'm wondering why when I run the following program (I'm running EG, 7.1), the table that opens up in the Output Data tab in EG shows the value labels ("Under 18", "18-24", or "25 and over") in the 'Age Range'n column, but when I open y.sas7bdat from the location in which I saved it, the table that is displayed just shows the value codes instead ("a", "b", or "c") for this column.
proc format;
VALUE $agerangef 'a' = 'Under 18'
'b' = '18-24'
'c' = '25 and over';
run;
data lib.y;
set x;
length 'Age Range'n $ 11;
if age<18 & age ~= . then 'Age Range'n = 'a';
else if age >= 18 & age<=24 then 'Age Range'n = 'b';
else if age >= 25 then 'Age Range'n = 'c';
format 'Age Range'n $agerangef.;
run;
Thanks!
If you mean "value labels" in the SPSS sense, then you will be disappointed. SAS uses Formats, which are session based and the data set contains a reference to the default Format name. If the format is not available at the time you use the data set you may get an error (if option FMTERR is in effect) or the default format for the variable type will be used to create a display.
To use the format the SAS session that opens the file will need to know where the format definition is.Which means that either the Proc Format code has to be submitted in that session or have the format in a permanent library and use system option FMTSEARCH to tell SAS to look in that library for format information in addition to the SAS system formats.
And if you are using some other program to view the SAS data set I suspect you will be just plain out of luck.
Thanks to both of you--this was driving me crazy trying to figure out!
If you mean "value labels" in the SPSS sense, then you will be disappointed. SAS uses Formats, which are session based and the data set contains a reference to the default Format name. If the format is not available at the time you use the data set you may get an error (if option FMTERR is in effect) or the default format for the variable type will be used to create a display.
To use the format the SAS session that opens the file will need to know where the format definition is.Which means that either the Proc Format code has to be submitted in that session or have the format in a permanent library and use system option FMTSEARCH to tell SAS to look in that library for format information in addition to the SAS system formats.
And if you are using some other program to view the SAS data set I suspect you will be just plain out of luck.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: