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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 426 views
  • 0 likes
  • 3 in conversation