BookmarkSubscribeRSS Feed
Lily07
Calcite | Level 5

I want to make a table with multiple observations per participant given certain conditions.

The conditions are:

1) the follow-up starts when event 1 occurs for the first time 

2) The participant isn't included if event 1 does not occur.

3) the time to event is calculated between the first time for event 1 and the following firstevent 2.

4) If event 2 occurs prior to event 1, it isn't counted.

 

So below is the example tables:

What I have

idevent1event2
120100108.
1.20110108
2.20110305
2 20130110
3.20110510
3 20140510
320160510.
420100210 
420100310 
4 20150220

 

What I want

idevent1event2censoreddays
120100108201101080365.5
320160510.11827.5
4201002102015022001470

 

Could you please help me to write the code? 

Thank you very much.

1 REPLY 1

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1 reply
  • 453 views
  • 0 likes
  • 2 in conversation