Fw: Transform Visit dates for each patients into visit days for each patients

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Fw: Transform Visit dates for each patients into visit days for each patients

John F Hall
Jacqueline didn't copy this to the list.
 
----- Original Message -----
Sent: Monday, February 15, 2010 1:49 PM
Subject: FW: Transform Visit dates for each patients into visit days for each patients

Dear Hans-Christian,

 

Please try the syntax below.  It should work I have tried it on some dummy data.

Please excuse my long comments, but I find they help.

 

All the best.

 

Jacqueline

 

-----------------------------------------

 

 

COMMENT warning - this syntax will only give you the correct data if you sort the data correctly.

 

COMMENT the data is sorted by the patients id first and then by their dates of attendance.

SORT CASES BY PID(A) VIS_DATE(A).

 

COMMENT this syntax identifies the first occurrence of any patient id number and puts a value of one for that first attendance.

IF  ((PID ~= LAG(PID,1))|($CASENUM=1)) FIRST=1.

EXECUTE.

 

COMMENT this puts the date of first visit alongside the first visit indicator .

IF  (FIRST =1) FIRST_date=VIS_DATE.

FORMATS FIRST_date (EDATE).

EXECUTE.

 

COMMENT this bit is still absolutely reliant on the prior sorting .

COMMENT This then looks for repetition of the patient id number and for each row that repeats the patient id it will repeat that row's dtate of first visit .

IF  (PID =LAG(PID,1)) FIRST_date=LAG(FIRST_date,1).

IF  (PID =LAG(PID,2)) FIRST_date=LAG(FIRST_date,2).

IF  (PID =LAG(PID,3)) FIRST_date=LAG(FIRST_date,3).

IF  (PID =LAG(PID,4)) FIRST_date=LAG(FIRST_date,4).

EXECUTE.

 

COMMENT this calculates the number of days between the date of the visit and the date allocated for that patient first visit.

COMPUTE VIS_DAY=DATEDIFF(VIS_DATE,FIRST_date,"DAYS").

EXECUTE.

 

 

 

 

 

 

Professor Jacqueline Collier
Tel:   0115 8230817         Mobile:   0771 781 401 8

Secretary   Shali Shah (Mon–Fri 10am-3pm)
[hidden email]
Tel:  0115 8230803       Fax: 0115 823 1208

 

From: John F Hall [mailto:[hidden email]]
Sent: 15 February 2010 11:22
To: Jacqueline Collier
Subject: Fw: Transform Visit dates for each patients into visit days for each patients

 

Jacquie

 

Can you help this guy at all?

 

John

 

----- Original Message -----

Sent: Monday, February 15, 2010 12:03 PM

Subject: Transform Visit dates for each patients into visit days for each patients

 


Dear SPSS List Members,

I have a dataset where the visit of a patient at an outdoor clinic is
the key of the dataset (VISID). Each visit case is characterized by an
patient id (PID) and a visit date (VIS_DATE). Therefore, each patient
id can appear more than one time.

Now I want to define a new variable: VIS_DAY.

I define the first visit of each patient by "day one". Problem: how do
I find the date of first visit for each patients and how do I write
this in SPSS syntax?

Then I want to define each visit of the respecitve patient by the
duration in days between the first visit and the respective date of
the visit.

Example:

VISID   PID             VIS_DATE                VIS_DAY
36              5               15 MAR 2010             1
58              5               16 MAR 2010             2
78              5               20 MAR 2010             6
3               6               16 MAR 2010             1
6               6               17 MAR 2010             2

Can someone helpt with the syntax for SPSS 18?

Thank you very much in advance!

Hans-Christian Stahl

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD


This message has been checked for viruses but the contents of an attachment may still contain software viruses which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.