Print actual namegroup and id in heading of each listing
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 | *(Q) I have a data file which includes name group identification var1 var2 and var3. * For each set of name group identification i need to produce a list of all cases within that set. I need to print the "name group identification" at the top of each listing. How can this be automated. *(A) Posted to SPSSX-L in July 2002 by Raynald Levesque. * http://pages.infinit.net/rlevesqu/index.htm. SET MPRINT=yes. DATA LIST LIST /name(A8) grp id var1 var2 var3. BEGIN DATA a 1 1 1 1 1 a 1 1 2 2 2 a 1 2 7 7 7 a 1 2 2 2 2 b 2 3 4 4 4 b 2 3 5 5 4 END DATA. LIST. SAVE OUTFILE='c:\\temp\\data.sav'. *//////////////. DEFINE !print(!POS=!TOKENS(1) /!POS=!TOKENSS(1) /!POS=!TOKENSS(1)) TEMPORARY. SELECT IF RTRIM(name)=RTRIM(!1) & grp=!2 & id=!3. SUMMARIZE /TABLES=name grp id /FORMAT=VALIDLIST NOCASENUM TOTAL /TITLE=!QUOTE(!CONCAT(!UNQUOTE(!1),' ',!2,' ',!3)) /MISSING=VARIABLE /CELLS=COUNT . !ENDDEFINE. *//////////////. AUTORECODE VARIABLE name /INTO namecode. SORT CASES BY namecode grp id. COMPUTE casenb=$CASENUM. RANK VARIABLES=casenb BY namecode grp id /RANK INTO r. SELECT IF r=1. WRITE OUTFILE='c:\\temp\\syntax.sps' /'!print "'name'" 'grp' 'id'.'. EXECUTE. GET FILE='c:\\temp\\data.sav'. INCLUDE 'c:\\temp\\syntax.sps'. |
Related pages
...