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 (July 2010, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 20 Jul 2010 17:15:13 -0400
Reply-To:     Nat Wooding <nathani@VERIZON.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Nat Wooding <nathani@VERIZON.NET>
Subject:      Re: How to code to calculate continuous 12 month period
In-Reply-To:  <201007202049.o6KICAoR006990@willow.cc.uga.edu>
Content-Type: text/plain; charset="US-ASCII"

Dave

Here is a variation of Chang's code.

Nat Wooding

%let NumMonths = 12; ** this is the number of months in the period that you are checking for;

Data Dave; Informat PatientID 8. Begin_Date mmddyy10.; input PatientID Begin_Date ; cards; 1 01/01/2009 1 02/01/2009 1 03/01/2009 1 06/01/2009 1 07/01/2009 1 08/01/2009 1 09/01/2009 1 10/01/2009 1 11/01/2009 1 12/01/2009 1 04/01/2010 2 05/01/2009 2 08/01/2009 2 09/01/2009 2 10/01/2009 2 11/01/2009 2 12/01/2009 2 01/01/2010 2 02/01/2010 2 03/01/2010 2 04/01/2010 2 05/01/2010 2 06/01/2010 2 07/01/2010 ; Data Selected; set dave; by PatientID; Format Begin_Date LastMO mmddyy10.; If first.patientid then do; Continuous_Months = 1 ; return; end; LastMo = Lag( Begin_Date ); if Intck( 'Month' , LastMO , Begin_Date ) = 1 then Continuous_Months +1; else Continuous_Months = 1;

if last.PatientID and Continuous_Months ge &NumMonths then output ; Drop LastMo;

run;

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Dave Brewer Sent: Tuesday, July 20, 2010 4:49 PM To: SAS-L@LISTSERV.UGA.EDU Subject: How to code to calculate continuous 12 month period

Hi All,

I have been trying to come up with code to calculate if a patient has been enrolled in Medicaid for 12 continuous months, but to no avail.

The data consists of a begin date (SAS date) and patient id. The end date will always be at the end of that month, so it is not needed.

Data: Patient ID Begin_Date 1 01/01/2009 1 02/01/2009 1 03/01/2009 1 06/01/2009 1 07/01/2009 1 08/01/2009 1 09/01/2009 1 10/01/2009 1 11/01/2009 1 12/01/2009 1 04/01/2010 2 05/01/2009 2 08/01/2009 2 09/01/2009 2 10/01/2009 2 11/01/2009 2 12/01/2009 2 01/01/2010 2 02/01/2010 2 03/01/2010 2 04/01/2010 2 05/01/2010 2 06/01/2010 2 07/01/2010

ID 1 would not be selected but ID 2 would. The continuous period does not have to be within a calendar year and I can have as few as 5 records and as many as 36 records, but the max number of records could change (up or down).

I would like the code to be dynamic; in other words, I might need to check for 24 continuous months the next time.

Thanks for your help. Dave


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