Blank bar for unselected category (generalized)
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 75 76 77 | *(Q) The AnswerNet solution 100001386 is great if you have only a single variable and you know which category has no respondents. * Unfortunately, I have 12 DB, with 5 to 20 variables in each DB. * Each variable does have the same possible values: 0.05, 1, 2, 3, 4, 17, 19, 20. * Is there any way to automate the process so that I don't have to run * all the frequencies for each DB, identify the variables and the * categories with no respondents, create separate files for each empty * category for each variable, etc.? *(A) Posted to SPSSX_L on 2001/12/06 by rlevesque@videotron.ca. * This is a fairly general solution. * You do not need to know the variable names nor which ones are missing category values before calling the macro. * You would call the macro once for each data file. (If you had many files you could use the technics described in the "Working with many files" section of this site to automate the process further). * errors are produced by macro when there are string variables in the data file but these can be ignored. SET MPRINT=no. *//////////////////////. DEFINE !fill (filenam=!TOKENS(1) /vlist=!CMDEND) GET FILE=!filenam. N OF CASES 1. !LET !cnt=!NULL !DO !val !IN (!vlist) DO REPEAT var=ALL. + COMPUTE var=!val. END REPEAT PRINT. !LET !cnt=!CONCAT(!cnt,!BLANK(1)) COMPUTE wgt=.00001. XSAVE OUTFILE=!QUOTE(!CONCAT('c:\\temp\\temp',!LENGTH(!cnt),'.sav')). !DOEND EXECUTE. GET FILE=!filenam. COMPUTE wgt=1. !LET !cntend=!LENGTH(!cnt) /* Add the dummy cases to the original data file */ !DO !cnt1=1 !TO !cntend ADD FILES FILE=* /FILE=!QUOTE(!CONCAT('c:\\temp\\temp',!cnt1,'.sav')). !DOEND EXECUTE. !ENDDEFINE. *//////////////////////. SET MPRINT=yes. * Call the macro to do the first data file. !fill filenam='C:\\program files\\spss\\employee data.sav' vlist=.05 1 2 3 4 7. * Show that it works. FORMAT jobcat minority (F8.2). WEIGHT BY wgt. * Basic Tables. TABLES /FORMAT BLANK MISSING('.') /TABLES jobcat BY minority > (STATISTICS) /STATISTICS count( ( F5.0 )). FREQUENCIES VARIABLES=jobcat /ORDER= ANALYSIS . * Note: Doing a Crosstab would not show the empty categories because that procedure round weights before preparing the table. |
Related pages
...