|
SPSS Folks,
I wonder if any of you might have advice about this problem. Here is the current structure of my data DATA LIST LIST/caseid cohort_flg Year 1 1 2000 1 0 2001 1 1 2001 2 1 2000 2 0 2001 3 0 2000 3 0 2001 3 0 2002 4 1 2000 END DATA. LIST. I want to create end up with the following where the second cohort flag is 1 for all cases who met the cohort criteria in preceding years. Caseid cohort_flg year cohort_flg2 1 1 2000 1 1 0 2001 1 1 1 2001 1 2 1 2000 1 2 0 2001 1 3 0 2000 0 3 0 2001 0 3 0 2002 0 4 1 2000 1 END DATA. LIST. I am working with a large (more than 1.5 million cases) dataset and want to find a way to code all cases as starting in a particular cohort that is as fast and efficient as possible. SPLIT FILE takes a very long time with this many cases, so I am hoping someone out there might be able to suggest some code that would be relatively quick but still get the job done. Peace, Jake ===================== 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 |
|
Seems to me (totally untested) that you could use the lag function to do this.
Sort cases by caseid year. Compute cohort_flg2=cohort_flg. If (caseid=lag(caseid)) cohort_flg2=lag(cohort_flg2). Melissa -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Jacob PK Gross Sent: Wednesday, April 02, 2008 9:25 AM To: [hidden email] Subject: [SPSSX-L] Assigning flag to cases with same caseid SPSS Folks, I wonder if any of you might have advice about this problem. Here is the current structure of my data DATA LIST LIST/caseid cohort_flg Year 1 1 2000 1 0 2001 1 1 2001 2 1 2000 2 0 2001 3 0 2000 3 0 2001 3 0 2002 4 1 2000 END DATA. LIST. I want to create end up with the following where the second cohort flag is 1 for all cases who met the cohort criteria in preceding years. Caseid cohort_flg year cohort_flg2 1 1 2000 1 1 0 2001 1 1 1 2001 1 2 1 2000 1 2 0 2001 1 3 0 2000 0 3 0 2001 0 3 0 2002 0 4 1 2000 1 END DATA. LIST. I am working with a large (more than 1.5 million cases) dataset and want to find a way to code all cases as starting in a particular cohort that is as fast and efficient as possible. SPLIT FILE takes a very long time with this many cases, so I am hoping someone out there might be able to suggest some code that would be relatively quick but still get the job done. Peace, Jake ===================== 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 PRIVILEGED AND CONFIDENTIAL INFORMATION This transmittal and any attachments may contain PRIVILEGED AND CONFIDENTIAL information and is intended only for the use of the addressee. If you are not the designated recipient, or an employee or agent authorized to deliver such transmittals to the designated recipient, you are hereby notified that any dissemination, copying or publication of this transmittal is strictly prohibited. If you have received this transmittal in error, please notify us immediately by replying to the sender and delete this copy from your system. You may also call us at (309) 827-6026 for assistance. ===================== 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 |
