| Date: | Sun, 29 Nov 1998 12:38:06 -0600 |
| Reply-To: | shiling@math.wayne.edu |
| Sender: | "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU> |
| From: | Shiling Zhang <shiling@MATH.WAYNE.EDU> |
| Organization: | Wayne State University |
|
| Content-Type: | text/plain; charset=us-ascii |
Liyan,
The first SQL solution I offered a couple days ago may delete observations
crossover ID groups.
The one below has three WHERE conditions appiled to the Cartesian product of a
given dataset.
conditions 1) and 2) subset the big Cartesian dataset into the original one.
And the third one delete the transfers within a ID group. If you have other
concerns, you may modify or add additional conditions into the where clause.
data t1;
input
@1 id @3 admis ddmmyy8. @12 disch ddmmyy8.;
format admis ddmmyy8. disch ddmmyy8.;
cards;
1 23/01/97 25/01/97
1 26/01/97 30/01/97
2 13/03/97 20/03/97
2 25/03/97 27/04/97
3 08/01/97 09/01/97
3 14/09/97 17/09/97
3 18/09/97 20/09/97
;
proc print; run;
proc sql;
select a.id, a.admis, a.disch
from t1 a,
t1 b
where a.id=b.id
and a.admis = b.admis
and (b.disch+1) not in
(select a.admis from t1 as a
where a.id=b.id)
order by a.id, a.admis
;
quit;
run;
Liu, Liyan HSURC wrote:
> Dear List-members,
>
> I am working with hospital discharge data. I'd like to create a subset
> excluding transfers(admitted to another hospital within one day of
> discharging from the former hospital, in the data below, ID 1 and 3 were
> transferred cases).
>
> My question is: how to delete the 2 records with * attached. Retain or lag
> command?
>
> id date of admission date of discharge
> 1 23/01/97 25/01/97 *
> 1 26/01/97 30/01/97
> 2 13/03/97 20/03/97
> 2 25/03/97 27/04/97
> 3 08/01/97 09/01/97
> 3 14/09/97 17/09/97 *
> 3 18/09/97 20/09/97
>
> Thanks.
>
> Liyan
>
> Liyan Liu
> Research Officer
> Health Services Utilization and Research Commission (HSURC)
> Box 46, 103 Hospital Drive
> Saskatoon, SK Canada S7N 0W8
>
> tel: (306) 655-1523
> fax: (306) 655-1462
> e-mail: liul@sdh.sk.ca
> website: http://www.sdh.sk.ca/hsurc/
|