Hello all,
I'am quite new to SAS EG and I want to get the following: I want to select all the measurements who have the highest percentage (from high to low per month AND section) till I reach a cumulative total percentage of minimal 75%. .
So (see screenshot) from the month July and section 2632CT I want to select just the percentage 53% + 28% in a cumulative column. For the month July and section 2646BT I want to select just 49% and 26% in cumulative etc. So I just want to select the highest percentages in a cumulative form until I reach a minimal of 75%. The count has to start from 0 again at the beginning of every new section (so actually 2x per month)
I hope its all clear, I appreciate your help.
Slight problem with the code suggested by @Kurt_Bremser . I'd use:
proc sort data=have out=need;
by maand1 sectie descending percentage;
run;
data want;
set need;
by maand1 sectie;
if first.sectie then sum_perc = 0;
if sum_perc lt .75 then do;
sum_perc+percentage;
output;
end;
drop sum_perc;
run;
Art, CEO, AnalystFinder.com
Sort by month, section and descending percentage;
Then do
data want;
set have;
by maand1 sectie;
if sum_perc le .75 then output;
if first.section
then sum_perc = percentage;
else sum_perc + percentage; /* causes automatic retain */
drop sum_perc;
run;
Slight problem with the code suggested by @Kurt_Bremser . I'd use:
proc sort data=have out=need;
by maand1 sectie descending percentage;
run;
data want;
set need;
by maand1 sectie;
if first.sectie then sum_perc = 0;
if sum_perc lt .75 then do;
sum_perc+percentage;
output;
end;
drop sum_perc;
run;
Art, CEO, AnalystFinder.com
Happens when you have no data to test against.
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 16. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: