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.
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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Get started using SAS Studio to write, run and debug your SAS programs.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.