BookmarkSubscribeRSS Feed
jude1
Fluorite | Level 6

I have a dataset that i need to find the quartiles for one variable then change the numbers of the quartiles into words (assign low to 0, mid-low to 1, etc...). I am not sure how to combine both and then save it to a new dataset. 

here is my code:

 

data mydata;

input var1 income population percentage;

datalines;

1 500 60 100%

2 400 70 90%

3 400 100 80%

4 800 222 80%

5 500 100 75%

6 600 213 70%

7 900 900 60%

8 1000 909 50%

9 100 600 40%

10 760 235 20%

;

run;


proc rank data=mydata groups=4 out=want;
var percentage;
ranks quartiles;

run;

 

I tried adding the proc format to the variable quartiles but i failed. 

Thank you.

2 REPLIES 2
PaigeMiller
Diamond | Level 26

Again, I request that you provide your data as working code, that does what you want; and not code that kinda sorta gets close to what you want but doesn't really work.

 

Here is how to use custom formats with PROC RANK.

 

proc format;
    value rankf 0='Low'; /* I'm lazy, you type the rest */
run;
proc rank data=mydata groups=4 out=want;
    var percentage;
    ranks quartiles;
    format quartiles rankf.;
run;

 

--
Paige Miller
Tom
Super User Tom
Super User
  • What variable specifically are you trying to attach a format to? 
  • What format are you trying to attach it? 
  • How did you define the format?
  • How did you try to attach the format to the variable?

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

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 2 replies
  • 1038 views
  • 2 likes
  • 3 in conversation