Thursday, November 5, 2009

Get nth value of a variable

It is another idea to get nth value of a variable.


proc sort data=sashelp.class out=tmp(keep=weight)
nodupkey;
by descending weight;
run;

data _null_;
set tmp end=end;

retain weight_10th .;
if _n_ <= 10 then do;
weight_10th = weight;
end;

if end then put "The 10th weight is " weight_10th=;
run;

No comments: