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

Hello!

Is it more efficient to replace Case when by proc Format?

 

Thanks 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Yes, it is more efficient and if you're doing it in more than one place, very recommended.

 


@ssafmed wrote:

Hello!

Is it more efficient to replace Case when by proc Format?

 

Thanks 


 

 

View solution in original post

3 REPLIES 3
Reeza
Super User

Yes, it is more efficient and if you're doing it in more than one place, very recommended.

 


@ssafmed wrote:

Hello!

Is it more efficient to replace Case when by proc Format?

 

Thanks 


 

 

ballardw
Super User

I would add that the larger the data set and the greater the number of "cases" involved the more friendly the use of a format becomes.

Case/when is pretty verbose plus requires running the entire data set through the transformation when the rules change. If your data set is large the time just to execute the transformation can become significant. Using a format on values for analysis or reporting pretty much skips that processing time.

 

Also a data set of values can be used to create formats if your rules are provided in a nice structure this may be a quick way to get the behavior you need.

PaigeMiller
Diamond | Level 26

Typically, PROC FORMAT uses less space in the SAS data set than creating the values as text strings. PROC FORMAT has a lot of other benefits as well ... one benefit is that if you decide your categories need to be changed, you can just change the format, rather than re-running the SQL to extract the data and apply the CASE statement.

--
Paige Miller

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 986 views
  • 4 likes
  • 4 in conversation