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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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