BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Astounding
PROC Star

Good observation.  Some of the suggestions so far may work.  However ...

 

If it is important to maintain the current order of the observations, and

 

If all values of your REMARK variable are non-blank,

 

you could try it this way:

 

data want;
conclusion = 'READY TO SELL';
do until(last.Part_No);
   set have;
   by Part_No;
   if remark = 'Hold in STOCK' then conclusion = remark;
end;
do until(last.Part_No);
  set have;
  by Part_No;
  output;
end;
run;
PeterClemmensen
Tourmaline | Level 20

What is the logic behind that conclusion='READY TO SELL' for Part_No =kk33 ?

jaiganesh
Obsidian | Level 7

Ohhh, I'm sorry , That  was my mistake , Please consider below one.

 

 

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

Jagadishkatam
Amethyst | Level 16

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;

 

 

 

Thanks,
Jag

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 18 replies
  • 1558 views
  • 3 likes
  • 5 in conversation