BookmarkSubscribeRSS Feed
FreelanceReinh
Jade | Level 19

Third question: Isn't this the same question as you asked in the other thread?

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Please don't post the same question multiple times.  To get a good response to your question post: test data, in the form of a datastep that covers your actual data and any differences - we can only work with what you give us.  Also post, what you want the output to look like, then any additional logic which may help.  Looking at your latest post, my post originally that was ignored should give you the result you want:

data have;
  input id term grade $ subj num;
  datalines;
10         2002        D            332        1 
10         2002        A              333       2
11         2005        C             232       1 
11         2005        A             232         2
11         2005        B             232        3
11         2005        C             232       4
15         2010       A              130        1
15         2010       B               130        2
15         2010       C              130        3 
;
run;
data want (keep=id term subj);
  length res $10;
  set have;
  retain res;
  by id term;
  if first.term then res="";
  res=cats(res,grade);
  if last.term and index(res,"ABC")>0 then output;
run;

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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
  • 16 replies
  • 4104 views
  • 0 likes
  • 8 in conversation