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

Hi all,

I am trying to collapse the levels of my categorical variable Readto_1617 from 4 to 3 levels.

These are the current levels. I must say, my current level when it comes to SAS is a beginner

 

value read /*readto_1617*/
1 = "0 days"
2 = "1-3 days"
3 = "4-6 days"
4 = "Every day"

 

I want  to combine 1= "0 days" and 2="1-3 days" such that my levels will now be

1 = "0 -3 days"
2 =  "4-6 days"
3 = "Every day"

Below was how it was formatted 

 

proc format;
value read /*readto_1617*/
1 = "0 days"
2 = "1-3 days"
3 = "4-6 days"
4 = "Every day";

run;

 

How do I change it to 3 levels? Thanks for the anticipated help

1 ACCEPTED SOLUTION

Accepted Solutions
LeonidBatkhan
Lapis Lazuli | Level 10

Hi microdire27,

Here is how you can change it to 3 levels:

proc format;
   value read 
      1,2 = "0 -3 days"
      3 = "4-6 days"
      4 = "Every day";
run;

Hope this helps.

 

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26

You talk about collapsing levels, which in this case has nothing to do with formats. It has to do with your data, which you need to show us (a portion of). We need to see the days.

--
Paige Miller
microdire27
Fluorite | Level 6
It is a large data set of about 71000 observations and 771 variables. Besides I can't find where I can attach the data file to along with this message.
PaigeMiller
Diamond | Level 26

I asked for a "portion of" your data, and the variable that contains days.

 

Anyway, perhaps you could just show us the (portion of) code that turns the days into 0, 1, 2, ... You can paste it right into your message by clicking on the "running man" icon and pasting it into the window that appears.

--
Paige Miller
LeonidBatkhan
Lapis Lazuli | Level 10

Hi microdire27,

Here is how you can change it to 3 levels:

proc format;
   value read 
      1,2 = "0 -3 days"
      3 = "4-6 days"
      4 = "Every day";
run;

Hope this helps.

 

microdire27
Fluorite | Level 6

It works. Thank you so much.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 5 replies
  • 2807 views
  • 1 like
  • 3 in conversation