Date: Wed, 30 Jul 2008 13:10:47 -0400
Reply-To: Jack Clark <jclark@HILLTOP.UMBC.EDU>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Jack Clark <jclark@HILLTOP.UMBC.EDU>
Subject: Re: Help with excluding events between two dates
In-Reply-To: A<62922.150.142.232.4.1217436492.squirrel@webmail.albany.edu>
Content-Type: text/plain; charset="us-ascii"
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
>
|