Dear SAS users, Do you have suggestions on how I can create different start and stop dates based on noncontinuous data points? For example, for each observation I want to create variables mon_start1, mon_end1, mon_start2, mon_end2, mon_start3, mon_end3, etc. I can create mon_start1 and mon_end1, but cannot figure out how to calculate the remaining variables (mon_start2, mon_end2, mon_start3, mon_end3, etc.) Here's a sample dataset for months Jan 2015 - Dec 2016 along with the beginning sas code where I created variables mon_start1 and mon_end1. For example, for ID=AA, the start/end variables should be as follows: mon_start1=1, mon_end1=6, mon_start2=10, mon_end2=18, mon_start3=22, mon_end3=24 data have; input id $ dob mmddyy10. total_mon mon1-mon24; format dob monyy7.; datalines; AA 01/11/2015 18 1 1 1 1 1 1 . . . 1 1 1 1 1 1 1 1 1 . . . 1 1 1 BB 01/29/2015 24 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 CC 08/23/2015 13 . . . . . . . 1 1 1 1 1 1 1 1 1 . . 1 1 1 1 . . DD 02/11/2015 20 . 1 1 1 . . . 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 EE 03/12/2016 8 . . . . . . . . . . . . . . 1 1 1 1 . 1 1 1 1 . ; data have2; set have; start=1; Mon_Start1=(intck('month','01Jan2015'd,dob))+1; array month mon:; do m=Mon_Start1-start+1 to dim(month) while(month[m]); end; if m>=24 then Mon_end1=total_mon; else Mon_End1=m-1; run; Thanks!
... View more