Hi,
I'm reading my data and then trying to use Proc Format. When I use Proc Print the initial values are not formatted. After reading some explanations I'm not sure why and need a bit of help. Thank you.
data mydata;
INFILE mysource dlm=',' missover;
input Site : $1.
Pt : $2.
Sex
Race
Dosedate : mmddyy10.
Height
Weight
Result1
Result2
Result3;
run;
proc format;
value Sex
1 = 'Female'
2 = 'Male';
value Race
1 = 'Asian'
2 = 'Black'
3 = 'Caucasian'
4 = 'other';
run;
proc print data=mydata;
run;
You created a format, you never applied it.
Proc print data=mydata;
Format sex sex. Race race.;
Run;
This would only apply to the proc print however. You may want to change the order, put the proc format before the data import step and add the format statement to your data step.
You'll want to call PROC FORMAT to create the formats before the data step. Then use them like other formats (Race Race., for example; like you might call Date monyy7.) in the data step.
Thanks... please see my next commet to Reeza.
You created a format, you never applied it.
Proc print data=mydata;
Format sex sex. Race race.;
Run;
This would only apply to the proc print however. You may want to change the order, put the proc format before the data import step and add the format statement to your data step.
Hi,
I moved the proc format to the top before the data step and ran the proc print using the format statement as suggested and to keep it simple for now... but it doesn't appear to affect the values.
Thank you.
I noticed these notes in the log if it matters:
30 proc format;
31 value Sex
32 1 = 'Female'
33 2 = 'Male';
NOTE: Format SEX is already on the library WORK.FORMATS.
NOTE: Format SEX has been output.
34 value Race
35 1 = 'Asian'
36 2 = 'Black'
37 3 = 'Caucasian'
38 4 = 'other';
NOTE: Format RACE is already on the library WORK.FORMATS.
NOTE: Format RACE has been output.
sorry for the bother... i didn't see the '.' after the format name but everything works now. Thank you!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.