Hello ,
I've a data like below
Part_No Remark
kk12 READY TO SELL
kk12 Hold in STOCK
kk22 READY TO SELL
kk22 READY TO SELL
kk22 Hold in STOCK
kk33 Hold in STOCK
kk33 Hold in STOCK
I need a output like
Part_No Remark conclusion
kk12 READY TO SELL Hold in STOCK
kk12 Hold in STOCK Hold in STOCK
kk22 READY TO SELL Hold in STOCK
kk22 READY TO SELL Hold in STOCK
kk22 Hold in STOCK Hold in STOCK
kk33 READY TO SELL READY TO SELL
kk33 READY TO SELL READY TO SELL
Need a column conclusion , Where the any Part_No has any Remark "Hold in STOCK " , Then conclusion would be all "Hold in STOCK" else conclusion would be "READY TO SELL".
Any Remark for the Part_No has "Hold in STOCK" should be given the conclusion as "Hold in STOCK"
Kindly respond with SAS Code
Please try the below code, only change to my previous code is i included an additional proc sort step
data have;
input Part_No$ Remark&$100.;
cards;
kk12 READY TO SELL
kk12 Hold in STOCK
kk22 READY TO SELL
kk22 READY TO SELL
kk22 Hold in STOCK
kk33 Hold in STOCK
kk33 READY TO SELL
;
PROC SORT DATA=have;
BY Part_No DESCENDING Remark;
RUN;
data want;
do until(last.Part_No);
set have;
by Part_No;
if last.Part_No then conclusion=Remark;
end;
do until(last.Part_No);
set have;
by Part_No;
output;
end;
run;
@jaiganesh wrote:
Hello ,
I've a data like below
Part_No Remark
kk12 READY TO SELL
kk12 Hold in STOCK
kk22 READY TO SELL
kk22 READY TO SELL
kk22 Hold in STOCK
kk33 Hold in STOCK
kk33 Hold in STOCK
I need a output like
Part_No Remark conclusion
kk12 READY TO SELL Hold in STOCK
kk12 Hold in STOCK Hold in STOCK
kk22 READY TO SELL Hold in STOCK
kk22 READY TO SELL Hold in STOCK
kk22 Hold in STOCK Hold in STOCK
kk33 READY TO SELL READY TO SELL
kk33 READY TO SELL READY TO SELL
Need a column conclusion , Where the any Part_No has any Remark "Hold in STOCK " , Then conclusion would be all "Hold in STOCK" else conclusion would be "READY TO SELL".
Any Remark for the Part_No has "Hold in STOCK" should be given the conclusion as "Hold in STOCK"
Kindly respond with SAS Code
Your rules do not explain your "want" values for kk33. There's not a single "READY TO SELL" in the "have" data.
I think what i ask was, I have the input data set (first ) and need a output like 2nd data set.
Where has conclusion column , Which is writing the conclusion on the basis of remark, If any of the remark say "Hold in STOCK " for individual part then , Entire Conclusion should say "Hold in STOCK " (for all individual lines in conclusion) else it should say " READY TO SELL"
Let me know if you need any other clarification.
@jaiganesh wrote:
I think what i ask was, I have the input data set (first ) and need a output like 2nd data set.
Where has conclusion column , Which is writing the conclusion on the basis of remark, If any of the remark say "Hold in STOCK " for individual part then , Entire Conclusion should say "Hold in STOCK " (for all individual lines in conclusion) else it should say " READY TO SELL"
Let me know if you need any other clarification.
Still does not make sense at all. What should be the result for kk33, and WHY?
And please show the code you tried on your own, I'm into helping, not into doing someone else's work for free.
What i mean is , If any remark for any part says "Hold in STOCK" then entire conclusion should be shown as "Hold in STOCK" else "Ready to Sell", Actual requirement is different, However this logic could be significant part of it.
I would appreciated if you can help to guide in any ways.
If that is the logic, then would you agree that your posted result is incorrect?
Ohhh, I'm sorry , That was my mistake , Please consider below onc.
I've a data like below
Part_No Remark
kk12 READY TO SELL
kk12 Hold in STOCK
kk22 READY TO SELL
kk22 READY TO SELL
kk22 Hold in STOCK
kk33 Hold in STOCK
kk33 READY TO SELL
I need a output like
Part_No Remark conclusion
kk12 READY TO SELL Hold in STOCK
kk12 Hold in STOCK Hold in STOCK
kk22 READY TO SELL Hold in STOCK
kk22 READY TO SELL Hold in STOCK
kk22 Hold in STOCK Hold in STOCK
kk33 Hold in STOCK Hold in STOCK
kk33 READY TO SELL Hold in STOCK
I've tried doing that with Some proc SQL Statement, However couldn't able to get the Robust solutions on this.
@jaiganesh wrote:
I've tried doing that with Some proc SQL Statement, However couldn't able to get the Robust solutions on this.
Show it, so we can tell you where your thinking went wrong. You learn most from your mistakes.
@jaiganesh wrote:
What i mean is , If any remark for any part says "Hold in STOCK" then entire conclusion should be shown as "Hold in STOCK" else "Ready to Sell", Actual requirement is different, However this logic could be significant part of it.
I would appreciated if you can help to guide in any ways.
Then your posted result for kk33 is wrong. Please correct it, or change the rules so that they explain the expected result. And show the code you tried.
Ohhh, I'm sorry , That was my mistake , Please consider below onc.
I've a data like below
Part_No Remark
kk12 READY TO SELL
kk12 Hold in STOCK
kk22 READY TO SELL
kk22 READY TO SELL
kk22 Hold in STOCK
kk33 Hold in STOCK
kk33 READY TO SELL
I need a output like
Part_No Remark conclusion
kk12 READY TO SELL Hold in STOCK
kk12 Hold in STOCK Hold in STOCK
kk22 READY TO SELL Hold in STOCK
kk22 READY TO SELL Hold in STOCK
kk22 Hold in STOCK Hold in STOCK
kk33 Hold in STOCK Hold in STOCK
kk33 READY TO SELL Hold in STOCK
Please suggest on this
@jaiganesh good. @Jagadishkatam gave you a working solution.
data have;
input Part_No$ Remark&$100.;
cards;
kk12 READY TO SELL
kk12 Hold in STOCK
kk22 READY TO SELL
kk22 READY TO SELL
kk22 Hold in STOCK
kk33 Hold in STOCK
kk33 Hold in STOCK
;
data want;
do until(last.Part_No);
set have;
by Part_No;
if last.Part_No then conclusion=Remark;
end;
do until(last.Part_No);
set have;
by Part_No;
output;
end;
run;
This would not help , As we are taking only last Remark for all parts, However my concern is , Which ever part has ANY Remark "HOLD ON STOCK " should come Conclusion as "HOLD ON STOCK " for all line for that parts, Else "Ready to sell" for all Lines.
Thanks in Advence
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 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.