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!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.