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
| id | event1 | event2 |
| 1 | 20100108 | . |
| 1 | . | 20110108 |
| 2 | . | 20110305 |
| 2 | 20130110 | |
| 3 | . | 20110510 |
| 3 | 20140510 | |
| 3 | 20160510 | . |
| 4 | 20100210 | |
| 4 | 20100310 | |
| 4 | 20150220 |
What I want
| id | event1 | event2 | censored | days |
| 1 | 20100108 | 20110108 | 0 | 365.5 |
| 3 | 20160510 | . | 1 | 1827.5 |
| 4 | 20100210 | 20150220 | 0 | 1470 |
Could you please help me to write the code?
Thank you very much.
Why is ID 3 in the output?
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.