how do we get three consecutive records with flag = 'Y after sorting dataset by USUBJID and Date?
data counter;
input usubjid $ flag $ date mmddyy10.;
format date mmddyy10.;
datalines;
A Y 1/01/2013
A Y 1/01/2013
A N 1/03/2013
A Y 1/04/2013
A Y 1/05/2013
A . 1/06/2013
A Y 1/07/2013
;
run;
The dataset is already sorted by usubjid and date, and there is no such sequence. Please explain (by posting an intended result) what you really want.
if suppose ,I have another data then how will I get the three consecutive 'Y'? how many ways we can find the three consecutive 'Y'?
@u52766097 wrote:
if suppose ,I have another data then how will I get the three consecutive 'Y'? how many ways we can find the three consecutive 'Y'?
Since your current example data contains no three consecutive 'Y', there is no way.
Provide example data that actually has three consecutive 'Y' and what the result should be.
And if there is another data (set?) you need to provide an example of that as well.
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 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.