Date: Tue, 1 Mar 2005 13:43:17 +1030
Reply-To: "Barnett, Adrian (HEALTH)" <adrian.barnett@HEALTH.SA.GOV.AU>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: "Barnett, Adrian (HEALTH)" <adrian.barnett@HEALTH.SA.GOV.AU>
Subject: Re: eliminate records where the person was re-admitted on the sam
e day that they were discharged
Content-Type: text/plain
Hi Thara
A couple of points:
(1) if someone was admitted only once, is the first row of a group of
records belonging to the one case, or is the first case in the file, they
won't be selected.
(2) the logic of the SELECT IF requires that the file is sorted in order of
personid, admission date and discharge date, so you need to ensure the file
is sorted in the way you described in your original posting
One way you can try to overcome this is to try the following (untested)
syntax:
Sort cases personid admdate disdate.
Do if (personid eq lag(personid)).
* grabs subsequent admissions which weren't on the same day they
were discharged from previous admission.
- if (admdate ne lag(disdate)) f = 1.
* ensure you grab the first record for a person and also
the first record in the file:.
Else if ((personid ne lag(personid)) or $casenum eq 1).
- compute f = 1.
End if.
Filter by f.
Hope this helps
Regards
Adrian
--
Adrian Barnett
Research & Information Officer Ph: +61 8 82266615
Research, Analysis and Evaluation Fax: +61 8
82267088
Strategic Planning and Research Branch
Strategic Planning and Population Health Division
Department of Health email:
Barnett.Adrian@saugov.sa.gov.au
God is good but don't dance in a currach. - Irish proverb
This e-mail may contain confidential information, which also may be legally
privileged. Only the intended recipient(s) may access, use, distribute or
copy this e-mail. If this e-mail is received in error, please inform the
sender by return e-mail and delete the original. If there are doubts about
the validity of this message, please contact the sender by telephone. It is
the recipient's responsibility to check the e-mail and any attached files
for viruses.
-----Original Message-----
From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of
Thara Vardhan
Sent: Tuesday, 1 March 2005 1:16
To: SPSSX-L@LISTSERV.UGA.EDU
Subject: eliminate records where the person was re-admitted on the same day
that they were discharged
Hi Hector
I tried the syntax that you have sent me but when i run the syntax i have no
records left in my data file. What have i done wrong?
What i am aiming to achieve is get a data file which will eliminate all such
records. I have checked my data file and i do have records where the person
has been re-admitted the same day that they were discharged.
I would really appreciate it if you could help me solve this problem.
regards
thara
Thara:
The simplest syntax is as follows:
SELECT IF (personid=lag(personid) and admdate NE LAG(disdate)).
This selects all records where the two records belong to the same person and
the second admission date is not equal to the discharge rate in the
precedent entry.
I recommend you save the working file (after this SELECT IF) under a new
name. Otherwise you will lose the deleted records forever, not a very clever
idea in general.
Hector
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf
> Of Thara Vardhan
> Sent: Monday, February 28, 2005 9:45 PM
> To: SPSSX-L@LISTSERV.UGA.EDU
> Subject: eliminate records where the person was re-admitted on the
> same day that they were discharged
>
>
> Dear List members
>
> can you please help me with a syntax for the following problem
>
> I want to eliminate records where the person was re-admitted on the
> same day that they were discharged. I want to write the syntax that
> will delete record b.
>
>
> for example my data contains records like these
>
> Personid admdate disdate
> 17152 27-MAY-2003 18-JUL-2003
> 17152 18-JUL-2003 26-SEP-2003
>
> Looking forward to your reply.
>
> regards
> thara
>
>
> Thara Vardhan
> Senior Project Officer
> Research, Planning & Evaluation Branch
> Tel: (02) 9219-9515
>
>
> This message is intended for the addressee named and may contain
> confidential information. If you are not the intended recipient,
> please delete it and notify the sender. Views expressed in this
> message are those of the individual
Thara Vardhan
Senior Project Officer
Research, Planning & Evaluation Branch
Tel: (02) 9219-9515
This message is intended for the addressee named and may contain
confidential information. If you are not the intended recipient, please
delete it and notify the sender. Views expressed in this message are those
of the individual sender, and are not necessarily the views of the
Department of Juvenile Justice.