Restructuring cases to vars

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Restructuring cases to vars

mcgannmary
Hello,
I've been using the Restructure Wizard in SPSS v24 to restructure cases to
variables. It's complicated because a row can include what appears to be
duplicate Patient IDs, episode dates and visit dates, but the reasons are
different so they are unique.
Using the table below, we see that Pt. ID 1 has only 1 Episode Dt of
5/10/18, with some Visit Dates that are the same as the Episode Date and
most are different, and each one has a different Visit Reason.  The Patient
ID and Episode date define a unique record and there can be many different
visit dates and visit reasons. I want to combine into one record the Pt ID,
Episode and visit Dates with the different reasons into one record, EXCEPT
for the rows that have the same Visit Dt even if the reason is different.


Pt. ID     Episode Dt         Visit Dt        Visit Reason
1     5/10/2018     5/10/18 New patient visit
1     5/10/2018        5/10/18 Labs
1     5/10/2018     6/20/18 Follow up
1     5/10/2018     12/8/18 Check up
1     5/10/2018     12/12/18 Radiology
1      5/10/2018     1/5/19        Check up
1       5/10/2018     1/5/19        Check up
1     5/10/18     1/30/19 Check up
1     5/10/18     2/24/19 Follow up

I've used the Pt. ID alone as the Identifying variable and I've tried using
the Pt. ID and Episode Dts as the Identifying variable, and I want the New
Patient Visit Reason to be the first one selected if there is more than 1
visit on the same date. I don't know how to do this

I'm not getting the rows that I'm looking for. Specifically, New Patient
visit isn't being selected as the first instance to keep, as I'm not sure
where or how to identify that. I have tried sorting by Pt ID, Episode and
Visit dates and selecting the first row, but that isn't always the New
Patient Visit.

I hope this makes sense and I look forward to your help!
Thanks,
Mary



--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: Restructuring cases to vars

David Marso-2
AGGREGATE the file (see FIRST function ) prior to the CASESTOVARS.

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: Restructuring cases to vars

spss.giesel@yahoo.de
Mary, you could start with sth. like this:
-------------------------------------------------

SORT CASES BY PID EDate VDate.
STRING VReasons (A100) /* Reasons are concatenated */.

DO IF ($CASENUM NE 1) AND (PID = LAG(PID)) AND (EDate = LAG(EDate)) AND (VDate = LAG(VDate)) .
- COMPUTE VReasons = CONCAT(LAG(VReason),';',vReason).
ELSE.
- COMPUTE VReasons = VReason.
END IF.
EXECUTE.

AGGREGATE
  /OUTFILE = 'yourpath\aggdata.sav'
  /PRESORTED
  /BREAK=PID EDate VDate
  /VReasons=LAST(VReasons).

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

Mario Giesel
Munich, Germany


Am Montag, 6. Mai 2019, 10:34:34 MESZ hat David Marso <[hidden email]> Folgendes geschrieben:


AGGREGATE the file (see FIRST function ) prior to the CASESTOVARS.

=====================
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
===================== 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