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
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.