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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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