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 (October 2011, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 7 Oct 2011 10:42:46 -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: Dates' gap
In-Reply-To:   <1317995458.19187.YahooMailNeo@web39421.mail.mud.yahoo.com>
Content-Type:   text/plain; charset="iso-8859-1"

Irin

I do not see anything wrong with the results when I run the code. In the following, I have added data for another ID value and instead of keeping only the obs that you want, instead, I set a flag if it is the first obs after a "gap. Additionally, I made the last obs of 9222 a "gap".

You need to change the If statement back to first.memid for two reasons: 1) If you are starting a new memid, you do not want to compare its date with the last date of the previous memid. 2) If you use last.memid and the last obs marks a gap, you will not include that gap in your data set.

Try running this code.

Nat

Data Irin1; informat memid $5. Enrdate EnrTermdate mmddyy10.; input memid $5. enrdate enrtermdate;

cards; 92222 01/10/2009 02/12/2009 92222 02/13/2009 03/22/2009 92222 03/30/2010 04/29/2010 * 92222 05/30/2010 06/10/2010 92222 06/12/2010 10/13/2010 * 92222 10/15/2010 12/31/2010 * note that this now follows a gap 92223 01/01/2008 01/30/2010 92223 01/31/2010 03/05/2011 92223 12/12/2011 01/05/2011 run; Data IrinWants; set irin1; by memid; if first.memid then return; if enrdate -lag(enrtermdate) gt 1 then flag = 'keep'; ** turned off if enrdate -lag(enrtermdate) gt 1 ;; format enr: mmddyy10.; run;

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Irin later Sent: Friday, October 07, 2011 9:51 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Dates' gap

Nat,

Thank you so much for the response.

However it looks like the output includes 9222 01/10/2009 record while it is not the one which appears after gap in coverage.

When I tested code on real data it looks like it takes the first record instead taking the next one which is the one AFTER break in coverage (gap)

I changed first.memid to last.memid: DataIrinWants;setirin1;bymemid;iflast.memid thenreturn;ifenrdate -lag(enrtermdate) gt 1;formatenr: mmddyy10.;run

After that it looks good except that it still extracts

Would it be possible to overcome the issue?

Thank you again!

Irin

From: Nat Wooding <nathani@VERIZON.NET> To: SAS-L@LISTSERV.UGA.EDU Sent: Friday, October 7, 2011 8:00 AM Subject: Re: Dates' gap

Irin

Try the following code. Also, by your rules, the fourth record should be output.

For any others who may play with this code, when I copied the data from the email, the blanks came across as a non-printing hex character that was different from a blank.

Nat Wooding

Data Irin1; informat memid $5. Enrdate EnrTermdate mmddyy10.; input memid $5. enrdate enrtermdate;

cards; 92222 01/10/2009 02/12/2009 92222 02/13/2009 03/22/2009 92222 03/30/2010 04/29/2010 * 92222 05/30/2010 06/10/2010 92222 06/12/2010 10/13/2010 * 92222 10/14/2010 12/31/2010 run; Data IrinWants; set irin1; by memid; if first.memid then return; if enrdate -lag(enrtermdate) gt 1 ; format enr: mmddyy10.; run;

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Irin later Sent: Friday, October 07, 2011 7:32 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Dates' gap

I have a table with multiple fragments of continues enrollment. I marke with astericks records after gap in dates

memid EnrDate enrTermDate 92222 01/10/2009 02/12/2009 92222 02/13/2009 03/22/2009 92222 03/30/2010 04/29/2010 * 92222 05/30/2010 06/10/2010 92222 06/12/2010 10/13/2010 * 92222 10/14/2010 12/31/2010

have to extract: - those records for each patients after gap in dates between fragments of enrollment . For example, I need for the patient with memid=92222 92222 03/30/2010 04/29/2010 * 92222 06/12/2010 10/13/2010 *

How can I implement it with ode? Could you please give me a hand? Thank you in advance,

Irin

;9222 10/14/2010 12/31/2010 recors although there is no gap between entermdate =10/13/2010 & enrdate=10/14/2010


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