Adding missing cases

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

Adding missing cases

Cory A. Crane
I have multilevel data in long format (56 report days for each of 420
participants). My problem is that participants did not submit a report for
each day of the study and these cases (e.g., participant 51, day 11;
Participant 51, day 44, etc) are not currently in the data set. I need to add
the missing cases and would appreciate any recommended syntax to accomplish
this task to avoid the time and potential for error that would accompany
manually adding all missing days.

=====================
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: Adding missing cases

Bruce Weaver
Administrator
You could use INPUT PROGRAM to generate a file with 56 report days for every participant, and then merge it with the original data file.  E.g.,

NEW FILE.
DATASET CLOSE all.

* Generate some sample raw data.
DATA LIST list / ID day Y (3f5.0).
BEGIN DATA
1 1 7
1 2 4
1 4 5
2 2 4
2 3 6
2 5 6
3 1 2
3 5 6
END DATA.
DATASET NAME raw.

INPUT PROGRAM.
LOOP #i = 1 to 3. /* Change to actual number of subjects.
LOOP #j = 1 to 5. /* OP change to actual number of days.
. COMPUTE ID = #i.
. COMPUTE day = #j.
END CASE.
END LOOP.
END LOOP.
END FILE.
END INPUT PROGRAM.
EXECUTE.
FORMATS ID day (f5.0).
DATASET NAME AllDays.

MATCH FILES
 file = Alldays /
 file = raw /
 by ID day.
EXECUTE.
DATASET NAME Final.
DATASET ACTIVATE Final.
LIST.

Output:
   ID   day     Y
 
    1     1     7
    1     2     4
    1     3     .
    1     4     5
    1     5     .
    2     1     .
    2     2     4
    2     3     6
    2     4     .
    2     5     6
    3     1     2
    3     2     .
    3     3     .
    3     4     .
    3     5     6
 
Number of cases read:  15    Number of cases listed:  15

HTH.


Cory A. Crane wrote
I have multilevel data in long format (56 report days for each of 420
participants). My problem is that participants did not submit a report for
each day of the study and these cases (e.g., participant 51, day 11;
Participant 51, day 44, etc) are not currently in the data set. I need to add
the missing cases and would appreciate any recommended syntax to accomplish
this task to avoid the time and potential for error that would accompany
manually adding all missing days.

=====================
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
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: Adding missing cases

David Marso
Administrator
In reply to this post by Cory A. Crane
DATASET DECLARE tmp .
MATRIX.
SAVE
 ({ KRONEKER( T({1:420}),MAKE(56,1,1)),
   KRONEKER(MAKE( 420,1,1),T({1:56}))})
  /OUTFILE tmp
  /VARIABLES Person day.
END MATRIX.
MATCH FILES
  / FILE tmp
  / FILE <your data file here>
  / BY Person Day.

Or look up INPUT PROGRAM in the FM or these archives and use nested  LOOP(s).

Cory A. Crane wrote
I have multilevel data in long format (56 report days for each of 420
participants). My problem is that participants did not submit a report for
each day of the study and these cases (e.g., participant 51, day 11;
Participant 51, day 44, etc) are not currently in the data set. I need to add
the missing cases and would appreciate any recommended syntax to accomplish
this task to avoid the time and potential for error that would accompany
manually adding all missing days.

=====================
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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"