BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
detective_jdee_
Calcite | Level 5

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!



1 ACCEPTED SOLUTION

Accepted Solutions
qoit
Pyrite | Level 9

Your format name is 'chol_status'

 

proc freq data=new;

table chol_status;

format chol_status chol_status.; run

;

View solution in original post

3 REPLIES 3
qoit
Pyrite | Level 9

Your format name is 'chol_status'

 

proc freq data=new;

table chol_status;

format chol_status chol_status.; run

;

detective_jdee_
Calcite | Level 5
I think the rules have recently changed (and you could correct me if I'm wrong), but now I know that the format names should be exactly the same as the variable names.

That worked. Thank you so much, qoit!

PaigeMiller
Diamond | Level 26

@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.

--
Paige Miller

SAS Innovate 2025: Call for Content

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 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 619 views
  • 3 likes
  • 3 in conversation