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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.