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 2008, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 30 Jul 2008 10:58:56 -0400
Reply-To:   Arthur Tabachneck <art297@NETSCAPE.NET>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Arthur Tabachneck <art297@NETSCAPE.NET>
Subject:   Re: Help with excluding events between two dates
Comments:   To: Richard Van Dorn <richard.vandorn@DUKE.EDU>

Richard,

I hadn't seen this post, or Jack's suggested code, before posting my previous, obviously insufficient code.

Jack's suggested code appears to do what you want but, before I delete the code, here is an alternative solution that appears to satisfy the same conditions:

data have; input ID SERVICE $ @9 DOS date9. @19 DOA date9. @29 DOD date9.; format dos doa dod date9.; cards; 1 Blood 07JAN1997 1 Blood 16JAN1997 16JAN1997 21JAN1997 1 Blood 19JAN1997 1 Fluid 19JAN1997 1 Blood 21JAN1997 1 Blood 08FEB1999 1 Blood 09FEB1999 09FEB1999 11FEB1999 1 Blood 10FEB1999 1 Blood 11FEB1999 2 Blood 07JAN1997 2 Blood 16JAN1997 16JAN1997 21JAN1997 2 Blood 19JAN1997 2 Fluid 19JAN1997 2 Blood 21JAN1997 2 Blood 21JAN1997 2 Blood 07FEB1999 07FEB1999 08FEB1999 2 Blood 09FEB1999 09FEB1999 11FEB1999 2 Blood 10FEB1999 2 Blood 11FEB1999 2 Blood 13FEB1999 3 Blood 13FEB1999 ; proc sql noprint; select max(maxcount) into :max_number from (select count(doa) as maxcount from have group by id) ; quit;

proc sort data=have; by id descending doa; run;

data want (keep=id service dos); array dates(&max_number.,2); retain dates; set have; by id; if first.id then stays=0; if not(missing(doa)) then do; stays+1; dates(stays,1)=doa; dates(stays,2)=dod; end; else do; test=0; do j=1 to stays; test=(dos ge dates(j,1)) * (dos le dates(j,2)); if test eq 1 then j=stays; end; if test eq 0 then output; end; run;

Art -------- On Wed, 30 Jul 2008 08:22:27 -0400, Richard Van Dorn <richard.vandorn@DUKE.EDU> wrote:

>Yes, I apologize. The admissions take place over the course of 8 years >and everyone has at least two admissions. > >Thanks. > >Jack Clark wrote: >> Richard, >> >> Your sample data does not show it, but can an ID have more than one >> admission? >> >> >> Jack >> >> >> >> Jack Clark >> Research Analyst >> phone: 410-455-6256 >> fax: 410-455-6850 >> jclark@hilltop.umbc.edu >> >> University of Maryland, Baltimore County >> Sondheim Hall, 3rd Floor >> 1000 Hilltop Circle >> Baltimore, MD 21250 >> >> >> >> >> Confidentiality Notice: This e-mail may contain information that is legally privileged and that is intended only for the use of the addressee (s) named above. If you are not the intended recipient, you are hereby notified that any disclosure, copying of this e-mail, distribution, or action taken in reliance on the contents of this e-mail and/or documents attributed to this e-mail is strictly prohibited. If you have received this information in error, please notify the sender immediately by phone and delete this entire e-mail. Thank you.-----Original Message----- >> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of >> Richard Van Dorn >> Sent: Wednesday, July 30, 2008 7:33 AM >> To: SAS-L@LISTSERV.UGA.EDU >> Subject: Help with excluding events between two dates >> >> Hello all. >> >> I have data that look like the following: >> >> ID SERVICE DOS DOA DOD >> 1 Blood 08FEB1999 . . >> 1 Blood 09FEB1999 09FEB1999 11FEB1999 >> 1 Blood 10FEB1999 . . >> 1 Blood 11FEB1999 . . >> >> Service is the service provided, DOS is the date of that service, DOA is >> the >> date of admission to the hospital and DOD is the date of discharge from >> the >> hospital. >> >> I need to retain all services that took place out the hospital. For >> example, >> in the data above, the only outpatient service was a blood draw on >> February >> 8, 1999. All other blood draws took place in the hospital. >> >> Thank you. >> Richard >> >>


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