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 (March 2011, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 2 Mar 2011 14:20:54 -0600
Reply-To:     "Data _null_;" <iebupdte@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Data _null_;" <iebupdte@GMAIL.COM>
Subject:      Re: Gap Determination
Comments: To: Dave <david.brewer@uc.edu>
In-Reply-To:  <201103021914.p22GLtEk012709@waikiki.cc.uga.edu>
Content-Type: text/plain; charset=ISO-8859-1

I think this is easier to understand and program when the data are in 24 rows vs 24 variables. I would also create SAS date to unsure proper order. The code below flips the data determines the gap length of each gap an numbers the gaps. You can compute the rest of the stats you need from this data.

data ins; input ID:$4. 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; 123 0 0 1 1 0 1 0 1 1 1 1 1 0 0 1 1 0 1 0 1 1 1 1 1 222 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 333 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ;;;; run; proc transpose out=ins2(rename=col1=flag); by id; run; data ins2; set ins2; month = input(cats('01',_name_,ifC(index(_name_,'1'),'2009','2010')),date.); format month monyy.; run; proc summary; by id flag notsorted; output out=gaps(drop=_type_ rename=(_freq_=gapLen)); run; data gaps; set gaps; by id; where flag eq 0; if first.id then gap = 0; gap + 1; run; proc print data=gaps; run;

On Wed, Mar 2, 2011 at 1:14 PM, Dave <david.brewer@uc.edu> wrote: > Hi SAS-Lers > > I have a data set with 24 variables (JAN1-DEC1, JAN2-DEC2), each > containing a 1 (has insurance coverage) or 0 (no insurance coverage). > > I need to find the following information for each person: > 1) Cumulative number of months an individual does not have insurance. > 2) Number of gaps in insurance (a patient could have a gap, become > insured and a gap again...thus the number of gaps would be 2 in this case) > 3) The length of each gap (measured in months)...call this GapLength1, > GapLength2, etc. > 4) The average gap length. > > Data looks like this (for sake of brevity, I am only showing the first 12 > months): > > ID JAN1 FEB1 MAR1 APR1 MAY1 JUN1 JUL1 AUG1 SEP1 OCT1 NOV1 DEC1 > 123 0 0 1 1 0 1 0 1 1 1 1 1 > 222 1 1 1 1 1 1 1 1 1 1 1 1 > 333 0 0 0 0 0 0 0 0 0 0 0 0 > > Thanks for your help. > Dave >


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