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!
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.