BookmarkSubscribeRSS Feed
u52766097
Fluorite | Level 6

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;

3 REPLIES 3
Kurt_Bremser
Super User

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.

u52766097
Fluorite | Level 6

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'?

ballardw
Super User

@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.

SAS Innovate 2025: Register Now

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!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 561 views
  • 0 likes
  • 3 in conversation