Copy some variables from each record type 1 to add a new record of type 0
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 | *(Q) I have nine record types called 1,2,3,4,5,6,7,8, and 9. * Record type 1 is really 2 record types lets say 0 and 1. * I need to split off the first 40 variables if the record is a background only record and call it record type 0. * In summary I need to add a new record type 0 for each record type 1. *(A) Posted to SPSS newsgroup by rlevesque@videotron.ca on 2002/01/11. * Create a data file for illustration purposes. DATA LIST LIST /id rectype var1 var2. BEGIN DATA 1 1 2 3 2 7 5 2 3 4 8 2 4 9 2 5 5 6 3 3 6 3 8 5 7 1 9 6 8 5 0 2 END DATA. LIST. * Create a few more dummy variables. VECTOR v(40F8). * Fill the variables with some data. LOOP #cnt=1 TO 40. COMPUTE v(#cnt)=TRUNC(UNIFORM(10)). END LOOP. ********************. * START the job. ********************. * Create a new record with rectype=0 for each case having rectype =1. LOOP #cnt=1 TO 1+ (rectype=1). + DO IF #cnt=2. + COMPUTE rectype=0. * Get rid of unneeded variables when rectype=0. + LOOP #cnt1=21 TO 40. + COMPUTE v(#cnt1)=$SYSMIS. + END LOOP. + END IF. + XSAVE OUTFILE='c:\\temp\\temp.sav' /KEEP=ALL. END LOOP. EXECUTE. GET FILE='c:\\temp\\temp.sav'. |
Related pages
...