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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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