## SAS mdy help for identifying gaps in claims coverage

Occasional Contributor
Posts: 7

# SAS mdy help for identifying gaps in claims coverage

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;

set claims2002;

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;

s = mdy (i,1, 2002);       * look for the end of the range;

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;

e = intnx ('month', mdy (i-1, 1, 2002), 1) - 1;

end;

j ++ 1;

end;

drop i j dummy;

run;

Any assistance would be greatly appreciated.

Thanks,

Rakesh

Super User
Posts: 13,583

## Re: SAS mdy help for identifying gaps in claims coverage

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= mdy(i, day,2002) ;

Or alternatively the first day of the next month - the number of days covered which is easier

s = mdy (i+1,1,2002) - m; But you have to address the end of year cases a bit differently since mdy (13,1,2002) has an invalid month. but if you data really include Jan to Aug should work but extension to longer periods is going to be somewhat awkward.

Occasional Contributor
Posts: 7

## Re: SAS mdy help for identifying gaps in claims coverage

Thank you very much for a prompt reply. Yes, the data I have is till december.

s = mdy(i,day,2002) looks like the route I want to take, but I am not able to figure out how to input the day value. I could have subtracted the number of days from the end of the month - 1 and that would return the exact day value. However, since the value is based on a variable and not a particular number. Please advise. Please let me know if you want further information. Meanwhile, I will try it out and post code here.

Thanks,

Rakesh

Super Contributor
Posts: 644

## Re: SAS mdy help for identifying gaps in claims coverage

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.

Richard

Super User
Posts: 13,583

## Re: SAS mdy help for identifying gaps in claims coverage

if i < 12 then s = mdy (i+1,1,2002) - m;

else s = mdy (1,1,2003) - m; should get you the date of interest for the starts. However hard coding years, or longer periods of data means you will need to address cross year values

And the array of days of months would need to be dependent on leap year status.

Discussion stats
• 4 replies
• 283 views
• 4 likes
• 3 in conversation