LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (August 2011, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 30 Aug 2011 07:10:15 -0400
Reply-To:     Dave <david.brewer@UC.EDU>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Dave <david.brewer@UC.EDU>
Subject:      Re: Gap Question, Part 3
Comments: To: Søren Lassen <s.lassen@POST.TELE.DK>
Content-Type: text/plain; charset=ISO-8859-1

Hi Soren,

Yes, you are correct about how to calculate cumulative gap months and everything works flawlessly.

Thanks for your help. Dave

On Tue, 30 Aug 2011 01:05:44 -0400, S=?ISO-8859-1?Q?=C3=B8ren?= Lassen <s.lassen@POST.TELE.DK> wrote:

>Dave, >As far as I can see, the new variable, cumulative gap months, is the >same as the original calculation of number of zeros. > >The easiest way to calculate the new number_zeros variable (total >number) is to use COUNT(): > >data dave2 (keep=Ngaps number_zeros cumulative_gap_length Avg_Gap_Length); >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; >seq=catt(of jan1--dec2); >number_zeros=count(seq,'0'); >/* convert zeros to blanks */ >seq=translate(seq,' ','0'); >/* delete single ones (neither coverage nor gaps) and preceding zeros */ >seq=left(tranwrd(' '!!seq,' 1 ',' ')); >if lengthn(seq) then do; /* if any coverage at all */ > /* ngaps=number of "words" -1 - in SAS 9.2 you can also use COUNTW */ > ngaps=count(seq,'1 ')-1; > /* total length of gaps */ > cumulative_gap_length=length(seq)-length(compress(seq)); > /* if there are no gaps, the average length stays missing */ > if ngaps then > avg_gap_length=cumulative_gap_length/ngaps; > end; >cards; >1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 0 0 0 0 1 1 1 1 1 >1 1 0 0 1 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 >1 1 0 1 0 1 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 >0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 >; >run; > >Regards, >Søren > >On Mon, 29 Aug 2011 05:59:48 -0400, Dave Brewer <david.brewer@UC.EDU> wrote: > >>Hi Soren, >> >>Thanks for the update. >> >>The investigator has changed his logic and I need an additional variable: >>Cumulative gap months. >> >>The confusion is over the definition of a gap. A gap length only occurs >>when an individual has two consecutive months of insurance coverage (the >>one's) and then at least one month without coverage (the 0's) and then >>regains insurance coverage for at least two months. >> >>Pattern could be: >> >>11011 >>1100000011111 >>11011111111 >>111111011111111 >>etc. >> >>Not gap patterns: >>000000001111111111111 >>111111110000000000000 >>100000000000111111111 >>000000000000000100000 >>etc. >> >>For instance the coverage pattern for this individual: >> >>0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 >> >>your coding found: >>average gap length: 3 (correct) >> >>Ngaps: 1 (correct) ---> there is only one gap, one sequence of the gap >>pattern. the zeroes at the beginning do not have at least two consecutive >>months with insurance leading into the gap. >> >>Number zeroes: 3 (incorrect) --- this should be the cumulative months >>without insurance which is 10 (10 zeroes) >> >>Additionally the cumulative gap months is missing (it would be 3 in this >>case). >> >>Cumulative gap months and cumulative months without insurance are two >>different metrics I am looking at. Cumulative gap months are the number of >>months without insurance that would fall in the gap pattern. Cumulative >>months without insurance are simply the total number of months without >>insurance (just sum all of the zeroes). >> >>Would it be possible to update your code to meet the new criteria? >> >>Thanks for your help and patience. >>Dave


Back to: Top of message | Previous page | Main SAS-L page