BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
zimcom
Pyrite | Level 9

 

 

data want; set have;
retain z;
if first.SUBJECT then z = 1;
else z = z + 1;
by SUBJECT;
run;

 

After I run the above code, how can I remove the SUBJECT if last.SUBJECT is less than 3 (not the observation of "z LT 3", but the SUBJECT), which means if the SUBJECT has less than 4 records, then they will be deleted.

 

Thanks as always

1 ACCEPTED SOLUTION
3 REPLIES 3
zimcom
Pyrite | Level 9
Thank you so much, really appreciated!
zimcom
Pyrite | Level 9

Another related question, in the dataset, now each subject has at least 4 records (up to the maximum of 6). I want to do another subset of only those subjects where the difference between the 2nd to 3rd, 3rd to 4th, 4th to 5th, etc., jumped great than 4 points from the previous one. 

 

Thanks again!

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 3 replies
  • 1000 views
  • 1 like
  • 2 in conversation