|
I can not figure this out. I am not skilled with loops (obviously).
ID Readmissions Days Readmits_seq 25 Primary Primary Primary 25 Transfer Transfer Transfer 25 readmit <=30 readmit 1 25 readmit <=30 readmit 2 25 readmit 91-180 readmit 3 25 Prime > 180 Prime 25 readmit <=30 readmit 1 25 Transfer Transfer Transfer 25 readmit <=30 readmit 1 25 Prime Other_Prim Prime 25 readmit <=30 readmit 1 Hospital Readmissions after Elapsed Days For patient ID number 25 I would like to number the readmissions sequentially after each occurrence of 'Transfer' or 'Prime' and do this for each patient ID. The fourth column gives the idea. ===================== 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 |
|
Gary,
This is not a loops problem. It is a straight forward do if structure problem. I haven't tested this and so there may be unanticipated problems. If there are, I'd like to know. Gene Maguin However, let me first straighten up the data which shows both the incoming data and the desired result. I now understand the that fourth column. I've added a fifth column with the actual value that I'm guessing you want to compute. Recode Readmissions('readmit' 'Prime'=1)(else=0) into start. Compute fifthcolumn=0. Execute. Do if (id eq lag(id). + do if (lag(start) eq 1). + compute start=1. + compute fifthcolumn=lag(fifthcolumn)+1. + end if. End if. >>I can not figure this out. I am not skilled with loops (obviously). Hospital Readmissions after Elapsed Days For patient ID number 25 I would like to number the readmissions sequentially after each occurrence of 'Transfer' or 'Prime' and do this for each patient ID. The fourth column gives the idea. ID Readmissions Days Readmits_seq fifthColumn 25 Primary Primary Primary . 25 Transfer Transfer Transfer . 25 readmit <=30 readmit 1 1 25 readmit <=30 readmit 2 2 25 readmit 91-180 readmit 3 3 25 Prime >180 Prime . 25 readmit <=30 readmit 1 1 25 Transfer Transfer Transfer . 25 readmit <=30 readmit 1 1 25 Prime Other_Prim Prime . 25 readmit <=30 readmit 1 1 ===================== 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 |
|
In reply to this post by Gary Stevens-2
1)Your example has a syntax error.
Add another ")" before the period: Do if (id eq lag(id). 2) As Gene points out, this is a conditional statement not a loop. 3) On the first record there is no prior ID. An example of code (for a different purpose) that explicitly handles this: COMPUTE RecNo = 1 . IF ($casenum>1 and ID=LAG(ID)) RecNo = LAG(RecNo) + 1 . Dennis Deck RMC Research -----Original Message----- From: Gary Stevens [mailto:[hidden email]] Sent: Wednesday, December 16, 2009 1:47 PM Subject: LOOP question I can not figure this out. I am not skilled with loops (obviously). ID Readmissions Days Readmits_seq 25 Primary Primary Primary 25 Transfer Transfer Transfer 25 readmit <=30 readmit 1 25 readmit <=30 readmit 2 25 readmit 91-180 readmit 3 25 Prime > 180 Prime 25 readmit <=30 readmit 1 25 Transfer Transfer Transfer 25 readmit <=30 readmit 1 25 Prime Other_Prim Prime 25 readmit <=30 readmit 1 Hospital Readmissions after Elapsed Days For patient ID number 25 I would like to number the readmissions sequentially after each occurrence of 'Transfer' or 'Prime' and do this for each patient ID. The fourth column gives the idea. ===================== 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 |
| Free forum by Nabble | Edit this page |
