|
I have a repeated measure data file as the example given below: ID Time Volume 1 1 500 1 2 550 1 3 400 1 4 300 1 5 200 2 1 1000 2 2 1100 3 1 450 3 2 350 3 3 250 If I wanted to make all cases have the same number of time points by adding missing values (rows) of volume for time points that are missing for each case - what is the easiest way to accomplish this in SPSS v.16? Thanks in advance for any suggestions. ====================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 |
|
At 02:33 PM 6/6/2008, Thomas, Dave wrote:
>I have a repeated measure data file as the example given below: |-----------------------------|---------------------------| |Output Created |09-JUN-2008 07:38:14 | |-----------------------------|---------------------------| ID Time Volume 1 1 500 1 2 550 1 3 400 1 4 300 1 5 200 2 1 1000 2 2 1100 3 1 450 3 2 350 3 3 250 Number of cases read: 10 Number of cases listed: 10 >If I wanted to make all cases have the same number of time points by >adding missing values (rows) of volume for time points that are >missing for each case - what is the easiest way to accomplish this >in SPSS v.16? For any version of SPSS having CASESTOVARS/VARSTOCASES, you can use "long-wide-long" code, as below. The awkward point is that the VARSTOCASES has to be hand-coded to match the set of variables transposed ('Time' and 'Volume', in your example), and the maximum number of instances observed in the input (5, in the example). Generating a VARSTOCASES to undo the effect of a preceding CASESTOVARS would be an interesting Python exercise, and very useful; but I don't know that anyone's done it. (I mean to, but haven't tackled it yet.) SORT CASES BY ID . CASESTOVARS /ID = ID /GROUPBY = VARIABLE . Cases to Variables |-----------------------------|---------------------------| |Output Created |09-JUN-2008 07:39:21 | |-----------------------------|---------------------------| Processing Statistics |---------------|---| |Cases In |10 | |Cases Out |3 | |---------------|---| |Cases In/Cases |3.3| |Out | | |---------------|---| |Variables In |3 | |Variables Out |11 | |---------------|---| |Index Values |5 | |---------------|---| VARSTOCASES /MAKE Time FROM Time.1 Time.2 Time.3 Time.4 Time.5 /MAKE Volume FROM Volume.1 Volume.2 Volume.3 Volume.4 Volume.5 /KEEP = ID /NULL = KEEP. Variables to Cases |-----------------------------|---------------------------| |Output Created |09-JUN-2008 07:41:40 | |-----------------------------|---------------------------| Generated Variables |------|------| |Name |Label | |------|------| |Time |<none>| |Volume|<none>| |------|------| LIST. List |-----------------------------|---------------------------| |Output Created |09-JUN-2008 07:41:40 | |-----------------------------|---------------------------| ID Time Volume 1 1 500 1 2 550 1 3 400 1 4 300 1 5 200 2 1 1000 2 2 1100 2 . . 2 . . 2 . . 3 1 450 3 2 350 3 3 250 3 . . 3 . . Number of cases read: 15 Number of cases listed: 15 ============================= APPENDIX: Test data, and code ============================= DATA LIST LIST / ID Time Volume (N2, F2, F5). BEGIN DATA 1 1 500 1 2 550 1 3 400 1 4 300 1 5 200 2 1 1000 2 2 1100 3 1 450 3 2 350 3 3 250 END DATA. LIST. SORT CASES BY ID . CASESTOVARS /ID = ID /GROUPBY = VARIABLE . LIST. VARSTOCASES /MAKE Time FROM Time.1 Time.2 Time.3 Time.4 Time.5 /MAKE Volume FROM Volume.1 Volume.2 Volume.3 Volume.4 Volume.5 /KEEP = ID /NULL = KEEP. LIST. ===================== 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 |
