1 = 0-4
2 = 5-17
3 = 18-49
4 = 50-64
5 = ≥65
In the article, 5 reasons to use PROC FORMAT to recode variables in SAS - The DO Loop, look for the PROC FORMAT step. That shows how to define a format. For example
proc format;
value YESNO
0 = "Yes"
1 = "No"
other = " ";
run;
proc freq data=covid1k;
format HospDeath IntenCare MechVent Asthma YESNO.;
tables HospDeath IntenCare MechVent Asthma;
run;
Show us what you have tried.
So, there are plenty of examples out there in the world of correct use of formats. @Rick_SAS has pointed you to some. Here is another example, from the SAS documentation: http://documentation.sas.com/doc/en/pgmmvacdc/9.4/proc/n03qskwoints2an1ispy57plwrn9.htm
See if you can follow any of those examples.
In the article, 5 reasons to use PROC FORMAT to recode variables in SAS - The DO Loop, look for the PROC FORMAT step. That shows how to define a format. For example
proc format;
value YESNO
0 = "Yes"
1 = "No"
other = " ";
run;
proc freq data=covid1k;
format HospDeath IntenCare MechVent Asthma YESNO.;
tables HospDeath IntenCare MechVent Asthma;
run;
Here is a short introduction to using PROC FORMAT to define a format:
"Use PROC FORMAT to recode variables in SAS"
As shown in the article, you use the FORMAT statement to tell that SAS to display a variable's formatted values instead of its raw values.
To "apply" a format to more than one variable, list all the variables after the word FORMAT and then put the name of the format at the end of the line. For example, to apply the YESNO format to four variables, you would use
format HospDeath IntenCare MechVent Asthma YESNO.;
Notice that the FORMAT statement needs to be INSIDE a DATA step or PROC/RUN boundary. It is not a global statement.
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!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.