BookmarkSubscribeRSS Feed
igsteo
Calcite | Level 5

I have to sort a dataset by 5 sizes i.e. size 1 (bottom 20%), size 2 (20-40%), size 3 (40-60%), size 4 (60-80%) and size 5 (top 20%). 

 

I require some feedback as to whether proc univariate or proc rank would be more approriate?

 

thank you

proc univariate data=iglib.mktcap6yrs noprint; 
by dsname;
var CY;
output out=mktcapsorted pctlpre=P pctlpts=10 to 100 by 20;
run;
proc rank  data= mydataset groups=5
    out=rankedset;
   by age;
   var var2;
   ranks varrank;
   ;
run;
3 REPLIES 3
Astounding
PROC Star
To sort the data use PROC SORT. If all you need is data in order by percentile then your work is done. The program doesn't assign percentile but it does put the data in the right order. If you need percentile assignments added to the data, you are not ready yet. You first need to decide how to handle ties. If half the data has a value of zero for the analysis variable, you have to choose. Do you want one percentile that is much larger than the others? Do you want to split the values so that the same value gets split across two (or more) percentiles? PROC RANK has options to easily apply any decision you might make along these lines.
igsteo
Calcite | Level 5

yup i just need to rank them from size 1 to 5 which i have managed to achieve through the proc rank group=5.

 

Is there a way to rename each rank? i.e. 0 = small...5=big.

Astounding
PROC Star

You wouldn't change the data.  But you could change how the values print by using PROC FORMAT, then apply the format when printing to translate the five numbers into words.

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
  • 1107 views
  • 0 likes
  • 2 in conversation