Date: Fri, 1 Jul 2011 10:12:07 -0400
Reply-To: Arthur Tabachneck <art297@ROGERS.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Arthur Tabachneck <art297@ROGERS.COM>
Subject: Re: GAP Question, Part 2
Dave,
There is probably a much more direct method and the following would have to
be carefully tested to ensure it is really doing what you want, but you
could try:
data dave (drop=gap: sum: i);
input jan1 feb1 mar1 apr1 may1 jun1 jul1 aug1 sep1 oct1 nov1 dec1
jan2 feb2 mar2 apr2 may2 jun2 jul2 aug2 sep2 oct2 nov2 dec2;
array amonths jan1--dec2;
array gap(24);
do i=24 to 3 by -1;
if gap(i) eq 1 and amonths(i-1) eq 0 then gap(i-1)=1;
else if amonths(i)+amonths(i-1) lt 2 then gap(i-2)=0;
else if amonths(i)+amonths(i-1) eq 2 and
amonths(i-2) eq 0 then gap(i-2)=1;
end;
sumgap=sum(of gap(*));
do i=1 to 23;
if gap(i) eq 1 and gap(i+1) eq 0 then gaps+1;
end;
if sumgap gt 0 then average=sumgap/gaps;
cards;
1 1 0 0 1 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0
;
run;
HTH,
Art
--------
On Fri, 1 Jul 2011 06:18:37 -0400, Dave <david.brewer@UC.EDU> wrote:
>Hi SAS-Lers,
>
>The pattern to determine a GAP in coverage is if anyone has at least TWO
>consecutive months of insurance coverage (the one's), at least ONE month
>without coverage (the zeroes), and then regains coverage for at least TWO
>consecutive months.
>
>Using the example pattern below, I need to calculate the Avg Gap Length
>(2+3/2) = 2.5 and Cumulative months without insurance = 5 (the number of
>zeroes between 11001100011).
>
>110011000110000000000000
>
>There could possible be instances where multiple gaps exist, this is just
>one example.
>
>I am running SAS 9.2 on a WIN7 box.
>
>Thanks much for your help.
>Dave
>
>
>data dave;
> input jan1 feb1 mar1 apr1 may1 jun1 jul1 aug1 sep1 oct1 nov1 dec1
> jan2 feb2 mar2 apr2 may2 jun2 jul2 aug2 sep2 oct2 nov2 dec2;
>cards;
>1 1 0 0 1 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0
>;
>run;
|