As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.


Here are some tips for How to share your SAS knowledge with your professional network.


Tips:Creating an Ordered Subset using PROC RANK

From sasCommunity
Jump to: navigation, search
 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)