Difference between revisions of "Tip of the Day:July 10"

From sasCommunity
Jump to: navigation, search
m (Scheduled Creating an Ordered Subset using PROC RANK)
(fix error that show page name instead of "comment")
 
Line 7: Line 7:
 
{{Tips:Creating an Ordered Subset using PROC RANK}}
 
{{Tips:Creating an Ordered Subset using PROC RANK}}
 
<div style="width:100%"><hr></div>
 
<div style="width:100%"><hr></div>
Feel free to [[Tips Talk:Creating an Ordered Subset using PROC RANK]] on this tip.
+
Feel free to [[Tips Talk:Creating an Ordered Subset using PROC RANK|comment]] on this tip.
 
</div>
 
</div>
 
</td></tr>
 
</td></tr>

Latest revision as of 18:51, 10 July 2017

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