Hello,
I thought it would be valuable to follow up to my previous post a few weeks ago regarding CTABLES Macro and share an additional feature that was added to the CTABLES program using Python. For each survey item, I wanted the description of the item to appear in the corner of the table using
/TITLES
CORNER='Description of survey item'.
where 'Description of survey item item' would be the Label for each item. The following change was needed:
/TITLES
CORNER=')TABLE'.
The full program is as follows:
begin program python.
import spss
varlist=['Q3a', 'Q3b', 'Q3c']
for var_bi in varlist:
spss.Submit("""
CTABLES
/VLABELS VARIABLES=%(var_bi)s DISPLAY=NONE
/PCOMPUTE &cat1 = EXPR([1] + [2])
/PPROPERTIES &cat1 LABEL = "Favorable" FORMAT=LAYERPCT.VALIDN 'Percentage' PCT40.0 HIDESOURCECATS=NO
/PCOMPUTE &cat2 = EXPR([3])
/PPROPERTIES &cat2 LABEL = "Neutral" FORMAT=LAYERPCT.VALIDN 'Percentage' PCT40.0 HIDESOURCECATS=NO
/PCOMPUTE &cat3 = EXPR([4] + [5])
/PPROPERTIES &cat3 LABEL = "Unfavorable" FORMAT=LAYERPCT.VALIDN 'Percentage' PCT40.0 HIDESOURCECATS=NO
/TABLE %(var_bi)s [C] [LAYERPCT.COUNT 'Percentage' PCT40.0, TOTALS[VALIDN F40.0, MEAN F40.2]]
/CATEGORIES VARIABLES=%(var_bi)s [&cat1, &cat2, &cat3, 1, 2, 3, 4, 5] EMPTY=INCLUDE TOTAL=YES
LABEL='Overall' POSITION=BEFORE
/TITLES
CORNER=')TABLE'.
""" %locals())
end program.
Thanks again to those who assisted!
Shane