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
proc sql;
create table want as
select *
from have
where subject not in (
select subject from have group by subject having count(subject) le 4
)
;
quit;
proc sql;
create table want as
select *
from have
where subject not in (
select subject from have group by subject having count(subject) le 4
)
;
quit;
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!
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!
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.