Editor's Note: Thanks to all who contributed to this solution. If the variable is numeric, there are also a number of procedures that can output the MAX statistic, including PROC MEANS and PROC REPORT.
It's actually quite simple to do.
After sorting your data the way is should (V1 descending V3), you just need to check the value of the FIRST automatic variable to identify the first observation of the V1 group.
Here's you're code with the modification:
proc sort data=work.dataset1 out=work.temp;
by V1 descending V3;
run;
data work.dataset2;
set work.temp;
by V1;
if first.V1; * first member of the group then output;
run;
Cheers from Portugal
Daniel Santos @ www.cgd.pt
Editor's Note: Thanks to all who contributed to this solution. If the variable is numeric, there are also a number of procedures that can output the MAX statistic, including PROC MEANS and PROC REPORT.
It's actually quite simple to do.
After sorting your data the way is should (V1 descending V3), you just need to check the value of the FIRST automatic variable to identify the first observation of the V1 group.
Here's you're code with the modification:
proc sort data=work.dataset1 out=work.temp;
by V1 descending V3;
run;
data work.dataset2;
set work.temp;
by V1;
if first.V1; * first member of the group then output;
run;
Cheers from Portugal
Daniel Santos @ www.cgd.pt
proc sort data=set1 out=set_sort;
by v1 descending v3;
run;
proc sort data=set_sort out=set_highest1 nodup;
by v1;
run;
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.