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 22:12:00 -0400
Reply-To:     Richard Van Dorn <richard.vandorn@DUKE.EDU>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Richard Van Dorn <richard.vandorn@DUKE.EDU>
Subject:      Re: Help with excluding events between two dates
Comments: To: msz03@albany.edu
In-Reply-To:  <46432.150.142.232.4.1217438660.squirrel@webmail.albany.edu>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Mike (and Muthia),

Thanks for your additional solutions to the problem that I posed; in addition to the solutions offered by Jack and Art I have learned a lot about how to handle this situation. I appreciate the time that the both of you spent in working on this issue.

Thanks again. Richard

Mike Zdeb wrote: > hi ... it does work with multiple admissions ... given the data that was posted, PROC FORMAT > produces a format with multiple date ranges for each unique ID, one data range per admission > > if you add the FMTLIB option to PROC FORMAT, you'll see the multiple date entries in each format > > it'll look awful here because of fonts, spacing, etc., but it's enough to see the results > > FORMAT NAME: FMT1_ LENGTH: 2 NUMBER OF VALUES: 2 > MIN LENGTH: 1 MAX LENGTH: 40 DEFAULT LENGTH 2 FUZZ: STD > START ,END ,LABEL (VER. V7|V8 30JUL2008:13:15:02) > 13530, 13535,OK > 14284, 14286,OK > > > FORMAT NAME: FMT2_ LENGTH: 2 NUMBER OF VALUES: 3 > MIN LENGTH: 1 MAX LENGTH: 40 DEFAULT LENGTH 2 FUZZ: STD > START ,END ,LABEL (VER. V7|V8 30JUL2008:13:15:02) > 13530, 13535,OK > 14282, 14283,OK > 14284, 14286,OK > > > there are two acceptable date ranges for ID=1 and three for ID=2 (and none for ID=3) > > when screening the data in a later data step, all the in-hospital date ranges are checked for each ID > > also, I tweaked the first data step a bit and it's now pretty short > > data fmx / view=fmx; > retain label 'OK'; > set have (rename=(doa=start dod=end)); > where start ne .; > fmtname = catt('fmt',id,'_'); > keep fmtname start end label; > run; > > proc format cntlin=fmx fmtlib; > run; > > data out_of_hosp; > set have; > where putn(dos,catt('fmt',id,'_10')) ne 'OK'; > run; > > proc print data=out_of_hosp; > var id service dos; > run; > > > > -- > Mike Zdeb > U@Albany School of Public Health > One University Place > Rensselaer, New York 12144-3456 > P/518-402-6479 F/630-604-1475 > > >> Mike, >> >> I don't think this solution will work for ID values with multiple >> admissions. Richard had stated that all IDs had at least 2 admissions. >> >> >> 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 >> Mike Zdeb >> Sent: Wednesday, July 30, 2008 12:48 PM >> To: SAS-L@LISTSERV.UGA.EDU >> Subject: Re: Help with excluding events between two dates >> >> hi ... some editing ... the DO UNTIL stuff remained from the >> trail-and-error phase ... to make the >> format, all that is needed is the following, making the whole job even >> shorter ... >> >> * write rules for the formats; >> data fmx / view=fmx; >> retain label 'OK'; >> set have; >> by id; >> where doa ne .; >> fmtname = catt('fmt',id,'_'); >> start = doa; >> end = dod; >> keep fmtname start end label; >> run; >> >> * create the format; >> proc format cntlin=fmx; >> run; >> >> * screen the data; >> data out_of_hosp; >> set have; >> where putn(dos,catt('fmt',id,'_10')) ne 'OK'; >> run; >> >> -- >> Mike Zdeb >> U@Albany School of Public Health >> One University Place >> Rensselaer, New York 12144-3456 >> P/518-402-6479 F/630-604-1475 >> >> >>> hi ... in the spirit of "there cannot be too many ways to answer a >>> >> question" ... another approach >> >>> is to create a format for each unique ID that has an entry for start >>> >> and end dates >> >>> then in a data step, use PUTN to pick the appropriate format to use >>> >> (based on the ID) and screen >> >>> the data >>> >>> in these data, ID = 3 has no start and end date, so there is no format >>> >> created for ID = 3 >> >>> however, since the WHERE statement looks for 'OK' and the absent >>> >> format produces a missing value, >> >>> this still works (and with no nasty messages in the LOG caused by that >>> >> missing format) >> >>> 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 >>> ; >>> run; >>> >>> * write rules for the formats; >>> data fmx / view=fmx; >>> retain label 'OK'; >>> do until (last.id); >>> set have; >>> by id; >>> where doa ne .; >>> fmtname = catt('fmt',id,'_'); >>> start = doa; >>> end = dod; >>> output; >>> end; >>> keep fmtname start end label; >>> run; >>> >>> * create the format; >>> proc format cntlin=fmx; >>> run; >>> >>> * screen the data; >>> data out_of_hosp; >>> set have; >>> where putn(dos,catt('fmt',id,'_10')) ne 'OK'; >>> run; >>> >>> proc print data=out_of_hosp; >>> var id service dos; >>> run; >>> >>> >>> -- >>> Mike Zdeb >>> U@Albany School of Public Health >>> One University Place >>> Rensselaer, New York 12144-3456 >>> P/518-402-6479 F/630-604-1475 >>> >>> >> > >


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