Quantcast

Question about breaking variable in aggregate

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Question about breaking variable in aggregate

Eva Wouda
Hello,

I have a longitudinal dataset containing follow-up days categorized on patientID (unfortunately a string…). It looks like this;
PatientID Fol_date Antibiotics (1=yes, 2=no) AntibioticsRec (1=yes 0=no)
12345-12 12-Jan-12 1 1
12345-12 13-Jan-12 1 1
12345-12 14-Jan-12 1 1
12345-12 15-Jan-12 1 1
12345-12 16-Jan-12 2 0
12346-12 23-Jun-12 1 1
12346-12 24-Jun-12 1 1
12346-12 25-Jun-12 2 0
12346-12 26-Jun-12 2 0
12346-12 27-Jun-12 1 1
12346-12 28-Jun-12 1 1
12346-12 29-Jun-12 1 1
12346-12 30-Jun-12 1 1
I am trying to get a variable telling me the amount of consecutive days of antibiotics used by patients. I did manage to get out the total days of antibiotics for each patient by using aggregate and then SUM of AntibioticsRec with break variables patientID and Antibiotics. There are some patients with several episodes of antibiotics and I like to know the number of days for these separate episodes (So “2" and “4" for patient 12346-12 instead of “6"). I don’t mind if two or three rows for the same patientID remain.

Thank you very much in advance,

Kind regards Eva

=====================
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
|  
Report Content as Inappropriate

Re: Question about breaking variable in aggregate

Maguin, Eugene
I think this but untested. Key element is "presorted" which will give a warning but you have to have the file unsorted by the antibiotics variable in order for the counting to work correctly.

sort cases by patientid fol_date.
Aggregate outfile=*/presorted/break=patientid antibiotics/ndays=nu.

Select if (antibiotics eq 1).
Execute.

Gene Maguin


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Eva Wouda
Sent: Monday, January 23, 2017 9:22 PM
To: [hidden email]
Subject: Question about breaking variable in aggregate

Hello,

I have a longitudinal dataset containing follow-up days categorized on patientID (unfortunately a string…). It looks like this;
PatientID Fol_date Antibiotics (1=yes, 2=no) AntibioticsRec (1=yes 0=no)
12345-12 12-Jan-12 1 1
12345-12 13-Jan-12 1 1
12345-12 14-Jan-12 1 1
12345-12 15-Jan-12 1 1
12345-12 16-Jan-12 2 0
12346-12 23-Jun-12 1 1
12346-12 24-Jun-12 1 1
12346-12 25-Jun-12 2 0
12346-12 26-Jun-12 2 0
12346-12 27-Jun-12 1 1
12346-12 28-Jun-12 1 1
12346-12 29-Jun-12 1 1
12346-12 30-Jun-12 1 1
I am trying to get a variable telling me the amount of consecutive days of antibiotics used by patients. I did manage to get out the total days of antibiotics for each patient by using aggregate and then SUM of AntibioticsRec with break variables patientID and Antibiotics. There are some patients with several episodes of antibiotics and I like to know the number of days for these separate episodes (So “2" and “4" for patient 12346-12 instead of “6"). I don’t mind if two or three rows for the same patientID remain.

Thank you very much in advance,

Kind regards Eva

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