I'm trying to run a do until loop in SAS for a set of stores with different SKU's and DCs to find a TSF_Qty for each SKU/DC combination. I am trying to sum up the SKU/DC's TSF_QTY as SUM_TSF_QTY and change the increment_percent until the SUM_TSF_QTY is greater than or equal to the netdcinv.
I was able to figure out how to sum the SKU's by DC, but found that when running the do until loop that it runs all stores at a 1.25 increment then only runs the do loop for one store causing a very high increment_percent. Can anyone help me figure out how to have it run the do loop for the entire store set and then sum it back up by sku_dc?
data Test3;
set TSF_Data (drop=location);
increment_percent=1;
do until(SUM_TSF_QTY>=netdcinv);
increment_percent=increment_percent+.25;
New_Max_Stock = (Increment_Percent * max_stock);
Need1 = (New_Max_Stock-Stock_on_hand);
need2 = round(need1,1);
Need3 = (need2/inner_pack_size);
Need4 = round(need3,1);
Final_Need = (need4*inner_pack_size);
if need1>0
then TSF_Qty = max(inner_pack_size,Final_Need);
else TSF_Qty=0;
by SKU_DC;
if first.SKU_DC then Sum_TSF_Qty=tsf_qty;
Sum_TSF_Qty+TSF_Qty;
if last.SKU_DC;
end;
run;
Didn't know of a better way to show the Sample Data. The first image is a sample of the input data. The second image is the current output I am getting. Since the do until is only running all stores once and then running the last store the increment_percent is much higher than desired.
Input and Output Sample Data Sets
Thanks