this is from BIST0535.hw3_1
As you can see I have sorted data by subject and then dov, such that the observations for a single subject are all clumped together and the observation from the first time they visited (date of visit, dov) is first. I need to create a new data set BIST0535.hw3_2 which contains only one observation from each subject with the first time they visited. I think we are meant to use an IF THEN statement, however if there is a easier way I am open to it.
1 | 07/09/1998 | 108 | 157 |
1 | 09/23/1998 | 107 | 134 |
2 | 10/15/1998 | 114 | 149 |
2 | 01/14/1999 | 112 | 165 |
2 | 04/15/1999 | 105 | 158 |
2 | 07/22/1999 | 115 | 143 |
3 | 07/22/1998 | 103 | 148 |
3 | 10/07/1998 | 107 | 165 |
3 | 01/14/1999 | 102 | 159 |
4 | 01/23/2000 | 87 | 110 |
4 | 04/26/2000 | 85 | 128 |
5 | 11/10/1999 | 65 | 137 |
5 | 02/10/2000 | 66 | 108 |
if i understand you,
all you need is
if first.subject;
data want;
set have;
by subject dov;
if first.subject;
run;
if i understand you,
all you need is
if first.subject;
data want;
set have;
by subject dov;
if first.subject;
run;
data want;
set have;
by subject;
if first.subject;
run;
Thank you! For some reason it was giving me an error about the BY statement, but i guess there was a need for a PROC SORT before this could occur.
Yes @MBlack732 By group processing does require ordering
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.