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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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