03-27-2014 04:19 PM
Hello SAS Users, I need your help with mdy problem. I am looking at coverage information and want to assign a start and end date to each patient based on the number of days information. I will subsequently count the gap period for further steps. I am creating seperate start and stop date base on the information that I have however, the code that I am using assigns the day value as first day of the month. In the example stated below, for patient 000004, if the patient is on insurance cov for just 15 days even then he is erroneously counted as starting from the 1st of June. Please let me know how I can modify the code below to account for the error.
PatiendID Jan Feb Mar Apr May Jun Jul Aug
0000001 0 28 31 30 31 30 31 31
0000002 31 28 31 30 31 30 31 31
0000003 31 28 31 30 31 30 31 31
0000004 0 0 0 0 0 15 21 31
Here is the code that I am using data coverage;
if sum (of enrind1-enrind12) NE ENRMON then
put "Eligible months in file does not agree with calculated. " ENROLID=;
array m enrind1-enrind12 dummy;
array s start1-start6;
array e end1-end6;
format start1-start6 end1-end6 mmddyy8.;
i = 1; j = 1; do while (i < 13); * look for a start of a range;
do while (i < 13 and m eq 0); i ++ 1; end; if i < 13 then do;
* found a start, assign the start date;
do while (i < 13 and m eq 1); i ++ 1; end; * found the end, assign the end date; * the end month is i-1, the end date is one * day before the start of the next month;
j ++ 1;
drop i j dummy;
Any assistance would be greatly appreciated.
03-27-2014 04:38 PM
I think your example data for patient 0000004 in July looks like a typo.
I think your are looking to assign a value such that if the previous month is 0, no coverage then you want the first day of coverage to be the the end day of the month minus the days covered plus. So for your example with patient 0000004 the first day of coverage would be day=30 - 15+1 = 16 June for coverage. That is the value you want for s
Or alternatively the first day of the next month - the number of days covered which is easier
03-28-2014 08:02 AM
Thank you very much for a prompt reply. Yes, the data I have is till december.
03-28-2014 09:35 AM
Why not create a temporary array that holds the number of days in each month?
Then the day number is (total days in month) - (days covered) + 1.
Date id then mdy(i, day_number, year) with no problems in December.
03-28-2014 11:32 AM
if i < 12 then s
And the array of days of months would need to be dependent on leap year status.