Fill the gaps when Aggregate has empty categories
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | *(Q) * stimcode (has 3 levels) respcode is supposed to have 4 levels (1 to 4) * for a total number of 12 combinations (cases). * However, some of the levels of respcode are missing. * The task is to fill the gaps. * For example when I have stimcode respcode rt N 128 1 128 2 128 3 128 4 129 1 129 2 129 3 129 4 130 2 130 3 130 4 *I want to add a case with 130 1 0 0 * (A) Posted to SPSSX-L list by rlevesque@videotron.ca on 2002/11/08. * The solution works for any 3 levels of stimcode but all 3 level must be present. * Create a data file for illustration purposes (note that 3 cases are missing). NEW FILE. DATA LIST LIST /stimcode respcode rt N. BEGIN DATA 128 1 128 2 128 3 128 4 129 3 129 4 130 2 130 3 130 4 END DATA. SAVE OUTFILE='c:\\temp\\data file.sav'. * find the 3 stimcode. SORT CASES BY stimcode. AGGREGATE OUTFILE=* /PRESORTED /BREAK=stimcode /tmp 'is not used'=n. COMPUTE rt=0. COMPUTE n=0. * create a file with the 12 potential "filldata" cases. LOOP respcode=1 TO 4. + XSAVE OUTFILE='c:\\temp\\temp.sav' /KEEP=stimcode respcode rt n. END LOOP. EXECUTE. * combine potential 'filldata" cases with the initial data file. ADD FILES FILE='c:\\temp\\temp.sav' /IN=filldata FILE='c:\\temp\\data file.sav'. SORT CASES BY stimcode respcode filldata. MATCH FILES FILE=* /BY stimcode respcode /FIRST=first. EXECUTE. * keep only "filldata" cases we need. SELECT IF first=1. * clean up. ADD FILES FILE=* /DROP=filldata first. EXECUTE. |
Related pages
...
Navigate from here