I am trying to pull in longitudinal data, and keep those with greater than 3 observations. I am using a first. last. statement to keep IDs and create an observation counter to ensure that I am keeping only those with greater than 3 observations. When I do this, the last observation is kept, and when I try to merge this back into the data set, the first observation is overwritten by the last observation being pulled from the first. last. How do I keep the first observation or at least avoid overwriting? Here is the code I am using: DATA UniqueID; SET Dementia; BY ID Age; IF First.ID = 1 THEN OBSCNT = 0; OBSCNT + 1; IF Last.ID = 1 AND OBSCNT GE 3; RUN;
... View more