Hello
I have a question.
If the value is equal to 12 then I need to divide the qty column to the EOQ column. The result will be spreading in the requested output until the total is 12. If the value less than 12 then I will keep it as it is.
Input | |
qty | EOQ |
12 | 4 |
0 | 4 |
0 | 4 |
0 | 4 |
0 | 4 |
0 | 4 |
0 | 4 |
0 | 4 |
4 | 4 |
0 | 4 |
0 | 4 |
0 | 4 |
2 | 4 |
0 | 4 |
0 | 4 |
12 | 4 |
0 | 4 |
0 | 4 |
0 | 4 |
0 | 4 |
0 | 4 |
0 | 4 |
0 | 4 |
Output | ||
qty | EOQ | Requested Output |
12 | 4 | 3 |
0 | 4 | 3 |
0 | 4 | 3 |
0 | 4 | 3 |
0 | 4 | 0 |
0 | 4 | 0 |
0 | 4 | 0 |
0 | 4 | 0 |
4 | 4 | 4 |
0 | 4 | 0 |
0 | 4 | 0 |
0 | 4 | 0 |
2 | 4 | 2 |
0 | 4 | 0 |
0 | 4 | 0 |
12 | 4 | 3 |
0 | 4 | 3 |
0 | 4 | 3 |
0 | 4 | 3 |
0 | 4 | 0 |
0 | 4 | 0 |
0 | 4 | 0 |
0 | 4 | 0 |
@hcbn Sorry Too late to notice your question, but whatever!!!
data have;
input qty EOQ;
cards;
12 4
0 4
0 4
0 4
0 4
0 4
0 4
0 4
4 4
0 4
0 4
0 4
2 4
0 4
0 4
12 4
0 4
0 4
0 4
0 4
0 4
0 4
0 4
;
data want;
set have;
retain k q;
if qty>0 then do; q=qty;k1=0;end;
if qty=12 then k=qty/EOQ;
k1+k;
k=ifn(q=12,(k1<=12)*k,qty);
drop k1 q;
run;
One way
data have;
input qty EOQ;
datalines;
12 4
0 4
0 4
0 4
0 4
0 4
0 4
0 4
4 4
0 4
0 4
0 4
2 4
0 4
0 4
12 4
0 4
0 4
0 4
0 4
0 4
0 4
0 4
;
data want(drop=c temp);
set have;
Requested_Output=qty;
if qty>0 then Requested_Output=qty;
if qty=12 then do;
Requested_Output=qty/EOQ;
temp=Requested_Output;
c=temp;
end;
if qty=0 and c<12 then do;
c=c+temp;
Requested_Output=temp;
end;
retain c temp;
run;
Sorry it does not correct accurately
@hcbn Sorry Too late to notice your question, but whatever!!!
data have;
input qty EOQ;
cards;
12 4
0 4
0 4
0 4
0 4
0 4
0 4
0 4
4 4
0 4
0 4
0 4
2 4
0 4
0 4
12 4
0 4
0 4
0 4
0 4
0 4
0 4
0 4
;
data want;
set have;
retain k q;
if qty>0 then do; q=qty;k1=0;end;
if qty=12 then k=qty/EOQ;
k1+k;
k=ifn(q=12,(k1<=12)*k,qty);
drop k1 q;
run;
@novinosrinThank you so much to you as well
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.