I am coding a distribution of flu vaccine. I allocate this vaccine to individual providers based on what they've ordered via various steps (for example, step 1 is allocating 10 doses of vaccine to providers who ordered < 500; step 2 is allocating 50 doses of vaccine to providers who ordered >= 500, etc). I have reached the end of my distribution and am left with a macro variable that is the remainder of doses (in this case, 160). I have updated each provider order based on steps 1-5 on the amount of vaccine I've already distributed and have an order_remaining - some provider orders have been completed (order_remaining = 0) and some provider orders are still in need of additional doses (order_remaining = 50). I've included a screenshot of part of my dataset below. I would like to distribute the remainder (160 doses) to fulfill the lowest remaining orders while the remainder > 0 in step 6. My thought was to use a do-while loop like: data test;
set vaccine_distribution;
remainder = &remainder;
do while (remainder > 0);
step_6 = order_remaining;
remainder + (-step_6);
end;
run; I want the code to distribute vaccine to the lowest volume of order_remaining in multiples of 10 while the remainder > 0. In the screenshot I've included and based on a remainder of 160, I would expect the orders of 30 and one of the orders of 50 to be completed with 40 vaccines remaining (i.e. 30, 30, 30, 50). I can't find any examples online of using a do while loop with the condition decreasing (i.e. remainder is going down each loop) rather than increasing and can't get the above code to complete. Thanks for your help!
... View more