My data looks like:
ID Start_day End_day
...
I am trying to first calculate the gap between a person's last end day and the next start day. e.g. for person 1, the gap should be 6/6/20 - 5/31/30 =6 days (which I already calculated for each person successfully).
Then, I want to calculate the duration for a person if he/she has no gap > 30 days. e.g. person 1 has gap > 30 days at the 4th row, so the duration should be 8/7/20 minus 5/1/20 (99 days).
Plus, a person could have multiple durations if he/she has more than one gap (>30 days). e.g. A person could have first duration on 5/1/10 - 5/1/11. Then, he/she have a gap of, for example, 180 days and he/she start another period 11/1/2011 - 1/31/11 and then they could have another gap of > 30 days. Then they could start a third period.
And add the desired output.
Question: are your start_day and end_day actually SAS date values?
You will in the long run save yourself a lot of headaches later if you get into the habit of using 4 digit years for display (unless of course you have a dinosaur-like boss that requires 2 digit years).
Quick, tell me what the date is in words for 01/02/03.
Without more information you might even get the wrong century.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: