How to subset data based on Proc Univariate's result?For eg: if i want to see the whole row and all the variables connected with an observation having highest and lowest value?
First sort descending, then choose the first 5 obs.
proc sort data=have;
by descending value ;
run;
data want;
do i=1 to 5;
set have point=i;
output;
end;
stop;
run;
Haikuo: update from ascending (my brainfart) to descending.
You could always open the dataset in a datastep, limiting the records included by using an if or where statement.
Thank you for the reply Arthur.
I have a cancer data.I used proc univariate to find out the maximum 5 values of the type of cancer.
Extreme Observations
-----Lowest---- -----Highest-----
Value Obs Value Obs
6790 6 572626 24
7544 12 2106499 26
12864 21 2477847 22
14098 11 5017159 1
14355 13 6081291 2
Now,how do i subset data which will contain only the records having observation number 1 , 2,24,26 and 22 (highest)?There is no variable that is unique for these observations(like no ssn no.etc)
Using if or where but how?
is there any provision that we can use_n_ = ?
Kindly help.
Regards,
Shaheen
First sort descending, then choose the first 5 obs.
proc sort data=have;
by descending value ;
run;
data want;
do i=1 to 5;
set have point=i;
output;
end;
stop;
run;
Haikuo: update from ascending (my brainfart) to descending.
Thank you !!
Regards,
Shaheen
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: