Tip of the Day:July 10

From sasCommunity
Jump to: navigation, search

sasCommunity Tip of the Day

 proc sort data=sashelp.class
          out=class;
   by sex;
   run;
 
proc rank data=class
          out=rank5(where=(rankwt le 5))
          descending;
   by sex;
   ranks rankwt;
   var weight;
   run;

Did you know that you can use PROC RANK to create subsets of observations within a group based on the value of an analysis variable? In this example we want the top 5 heaviest weights within each level of SEX. Remove the keyword DESCENDING to save the 5 lightest weights.


Adding the TIES=LOW option on the PROC RANK statement allows you to collect ties as well (you may end up with more than just the specified number of observations).

Submitted By Art Carpenter (talk)



Feel free to comment on this tip.


Prior tip - Next tip - Random Tip

Submit a Tip