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?

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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