@E_W wrote:
Sure. The cumulative sum is what I have currently using a Retain command to sum up the offers by Zip Code. The offers themselves are arranged by quality ranking assigned to each offer for each Zip Code.
Status is something I put in to reject all entries where the cumulative sum is greater than the Zip Code limit. I can take that out for now.
Zip Quality Ranking Offer Zip Code Limit Cumulative Sum
10002 300 $650 $1,000 $650
10002 275 $200 $1,000 $850
10002 270 $400 $1,000 $1250
10002 255 $100 $1,000 $1350
10002 250 $50 $1,000 $1400
The expected appearance should be the table above along with a 6th Column stating whether the offer is Accepted or Rejected.
Still not clear why just because you skip the third one you can't accept the 4th. Your subject line says "skipping certain entries" you example is "stop at some rule" but no quite clearly stating the stopping rule.
It looks like two variables need to be Retained (and reset in changes in Zip) the cumulative sum and a second one that you test to see if the total would have been previously exceeded.
data want;
set have;
by zip;
retain cumsum flag;
if first.zip then do;
cumsum=0;
flag=0;
end;
cumsum+offer;
if cumsum le ziplimit and flag=0 then status='Accept';
else if cumsum > ziplimit then do;
flag=1;
status='Reject';
end;
run;
The Flag variable is an indicator for the cumulative sum would have been exceeded and is used to not accept any further "accept" values. If this works as you need you could drop the Flag variable.
This worked for your limited data.
... View more