Hi everyone,
I submitted the following code onto a program in SAS ODA account:
Data new;
set cert.input44;
drop bp_status weight_status smoking_status;
if cholesterol=. then chol_status=.;
else if cholesterol<200 then chol_status=1;
else if 200<=cholesterol<=239 then chol_status=2;
else if cholesterol>=240 then chol_status=3;
run;
proc format;
value chol_status 1="Safe" 2="High to Borderline" 3="High";
run;
proc freq data=new;
table chol_status;
format chol_status cholcat.;
run;
This exactly follows the structure of examples that have worked for me before. However, this time when I run the proc freq step, the "Safe" "High to Borderline" and "High" formats are not applied to the output, and I'm not sure why that is.
How could I make sure my formats are correctly applied?
Help would be much appreciated.
Thank you!
Your format name is 'chol_status'
proc freq data=new;
table chol_status;
format chol_status chol_status.; run
;
Your format name is 'chol_status'
proc freq data=new;
table chol_status;
format chol_status chol_status.; run
;
@detective_jdee_ wrote:
I think the rules have recently changed (and you could correct me if I'm wrong),
No, they have not, rules for formats have not changed in decades ...
but now I know that the format names should be exactly the same as the variable names.
... this is also incorrect. Your original code did not use the format name, that was the problem. One format can be applied to many variables, if you use the name of a format that has been defined.
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.