For tutorial purposes (elaboration of a dependent variable by an independent variable controlling for a test variable) I need contingency tables in a format which CROSSTABS cannot display. I’ve been experimenting with the syntax in CTABLES (basically editing/copy/pasting syntax originally supplied by Jon Peck) and have finally managed to come up with syntax to get the sort of contingency tables I want. When doing all this, I found the FM (and my 1960s Algol programming) far more useful than the GUI. After a zillion attempts (and no trees pulped for output) I got as far as: ctables /TABLE sex [c] BY happy [C] [ROWPCT.COUNT TOTALS[COUNT]] /CATEGORIES VARIABLES= sex happy TOTAL=YES POSITION=AFTER /TABLE marital [C] BY happy [C] [ROWPCT.COUNT TOTALS[COUNT]] /CATEGORIES VARIABLES= marital happy TOTAL=YES POSITION=AFTER /table marital > sex by happy [ROWPCT.COUNT TOTALS[COUNT]] /CATEGORIES VARIABLES= sex marital happy TOTAL=YES POSITION=AFTER.
These tables are still visually cluttered (and some run off the edge of pages in Word). For now I can edit them manually to change the column headings from Row N % to % and Count to n = 100% and delete the trailing % in the table cells, as in:
Is there any way I can specify these column headers and cell contents in CTABLES syntax (and/or omit the variable names as the table below)?
John F Hall (Mr) [Retired academic survey researcher] Email: [hidden email] Website: www.surveyresearch.weebly.com SPSS start page: www.surveyresearch.weebly.com/1-survey-analysis-workshop |
ctables   /VLABELS VARIABLES=marital happy DISPLAY=NONE    /TABLE sex [c] BY happy [C]  [ROWPCT.COUNT "%" TOTALS[COUNT "n= 100%"]]    /CATEGORIES VARIABLES= sex  happy TOTAL=YES POSITION=AFTER    /TABLE  marital [C]  BY happy [C]  [ROWPCT.COUNT "%" TOTALS[COUNT "n= 100%"]]   /CATEGORIES VARIABLES=  marital happy TOTAL=YES POSITION=AFTER   /table marital > sex by happy [ROWPCT.COUNT "%" TOTALS[COUNT "n= 100%"]]   /CATEGORIES VARIABLES= sex marital happy TOTAL=YES POSITION=AFTER. On 26 September 2014 05:44, John F Hall <[hidden email]> wrote:
|
Slight tweak to set the formats of the table cells also: ctables   /VLABELS VARIABLES=marital happy DISPLAY=NONE    /TABLE sex [c] BY happy [C]  [ROWPCT.COUNT f8.1 "%" TOTALS[COUNT f8.0 "n= 100%"]]    /CATEGORIES VARIABLES= sex  happy TOTAL=YES POSITION=AFTER    /TABLE  marital [C]  BY happy [C]  [ROWPCT.COUNT f8.1 "%" TOTALS[COUNT v "n= 100%"]]   /CATEGORIES VARIABLES=  marital happy TOTAL=YES POSITION=AFTER   /table marital > sex by happy [ROWPCT.COUNT f8.1 "%" TOTALS[COUNT f8.0  "n= 100%"]]   /CATEGORIES VARIABLES= sex marital happy TOTAL=YES POSITION=AFTER. On 26 September 2014 11:07, Jignesh Sutar <[hidden email]> wrote:
|
Jignesh Many thanks for this but first try got an error message:
Took me a moment or two to find the culprit, but I deleted the v in [COUNT v "n= 100%"] . . and it worked perfectly. Did a tweak of my own to hide the name display for sex and got an even better set of tables. Thanks a million. John John F Hall (Mr) [Retired academic survey researcher] Email:  [hidden email] Website: www.surveyresearch.weebly.com SPSS start page: www.surveyresearch.weebly.com/1-survey-analysis-workshop (Source: Quality of Life in Britain, 1975)Â
From: [hidden email] [mailto:[hidden email]] On Behalf Of Jignesh Sutar Slight tweak to set the formats of the table cells also: ctables /VLABELS VARIABLES=marital happy DISPLAY=NONE /TABLE sex [c] BY happy [C] [ROWPCT.COUNT f8.1 "%" TOTALS[COUNT f8.0 "n= 100%"]] /CATEGORIES VARIABLES= sex happy TOTAL=YES POSITION=AFTER /TABLE marital [C] BY happy [C] [ROWPCT.COUNT f8.1 "%" TOTALS[COUNT v "n= 100%"]] /CATEGORIES VARIABLES= marital happy TOTAL=YES POSITION=AFTER /table marital > sex by happy [ROWPCT.COUNT f8.1 "%" TOTALS[COUNT f8.0 "n= 100%"]] /CATEGORIES VARIABLES= sex marital happy TOTAL=YES POSITION=AFTER. On 26 September 2014 11:07, Jignesh Sutar <[hidden email]> wrote: ctables /VLABELS VARIABLES=marital happy DISPLAY=NONE /TABLE sex [c] BY happy [C] [ROWPCT.COUNT "%" TOTALS[COUNT "n= 100%"]] /CATEGORIES VARIABLES= sex happy TOTAL=YES POSITION=AFTER /TABLE marital [C] BY happy [C] [ROWPCT.COUNT "%" TOTALS[COUNT "n= 100%"]] /CATEGORIES VARIABLES= marital happy TOTAL=YES POSITION=AFTER /table marital > sex by happy [ROWPCT.COUNT "%" TOTALS[COUNT "n= 100%"]] /CATEGORIES VARIABLES= sex marital happy TOTAL=YES POSITION=AFTER. On 26 September 2014 05:44, John F Hall <[hidden email]> wrote: ctables /TABLE sex [c] BY happy [C] [ROWPCT.COUNT TOTALS[COUNT]] /CATEGORIES VARIABLES= sex happy TOTAL=YES POSITION=AFTER /TABLE marital [C] BY happy [C] [ROWPCT.COUNT TOTALS[COUNT]] /CATEGORIES VARIABLES= marital happy TOTAL=YES POSITION=AFTER /table marital > sex by happy [ROWPCT.COUNT TOTALS[COUNT]] /CATEGORIES VARIABLES= sex marital happy TOTAL=YES POSITION=AFTER. |
I would like to point out, John, that the
option for setting the statistics labels is clear if you use the GUI. The
same grid where you select the statistics has a column for the label (and
a column for the format).
Jon Peck (no "h") aka Kim Senior Software Engineer, IBM [hidden email] phone: 720-342-5621 From: John F Hall <[hidden email]> To: [hidden email] Date: 09/26/2014 04:52 AM Subject: Re: [SPSSX-L] Column headers and cell formats in CTABLES Sent by: "SPSSX(r) Discussion" <[hidden email]> Jignesh
Many thanks for this but first try got an error message:
Took me a moment or two to find the culprit, but I deleted the v in [COUNT v "n= 100%"] . . and it worked perfectly. Did a tweak of my own to hide the name display for sex and got an even better set of tables.
Thanks a million. John
John F Hall (Mr) [Retired academic survey researcher]
Email: johnfhall@... Website: www.surveyresearch.weebly.com SPSS start page: www.surveyresearch.weebly.com/1-survey-analysis-workshop
(Source: Quality of Life in Britain, 1975)
From: [hidden email] [mailto:jignesh.sutar@...]
On Behalf Of Jignesh Sutar
Slight tweak to set the formats of the table cells also:
ctables /VLABELS VARIABLES=marital happy DISPLAY=NONE /TABLE sex [c] BY happy [C] [ROWPCT.COUNT f8.1 "%" TOTALS[COUNT f8.0 "n= 100%"]] /CATEGORIES VARIABLES= sex happy TOTAL=YES POSITION=AFTER /TABLE marital [C] BY happy [C] [ROWPCT.COUNT f8.1 "%" TOTALS[COUNT v "n= 100%"]] /CATEGORIES VARIABLES= marital happy TOTAL=YES POSITION=AFTER /table marital > sex by happy [ROWPCT.COUNT f8.1 "%" TOTALS[COUNT f8.0 "n= 100%"]] /CATEGORIES VARIABLES= sex marital happy TOTAL=YES POSITION=AFTER.
On 26 September 2014 11:07, Jignesh Sutar <jsutar@...> wrote: ctables /VLABELS VARIABLES=marital happy DISPLAY=NONE /TABLE sex [c] BY happy [C] [ROWPCT.COUNT "%" TOTALS[COUNT "n= 100%"]] /CATEGORIES VARIABLES= sex happy TOTAL=YES POSITION=AFTER /TABLE marital [C] BY happy [C] [ROWPCT.COUNT "%" TOTALS[COUNT "n= 100%"]] /CATEGORIES VARIABLES= marital happy TOTAL=YES POSITION=AFTER /table marital > sex by happy [ROWPCT.COUNT "%" TOTALS[COUNT "n= 100%"]] /CATEGORIES VARIABLES= sex marital happy TOTAL=YES POSITION=AFTER.
On 26 September 2014 05:44, John F Hall <johnfhall@...> wrote: ctables /TABLE sex [c] BY happy [C] [ROWPCT.COUNT TOTALS[COUNT]] /CATEGORIES VARIABLES= sex happy TOTAL=YES POSITION=AFTER /TABLE marital [C] BY happy [C] [ROWPCT.COUNT TOTALS[COUNT]] /CATEGORIES VARIABLES= marital happy TOTAL=YES POSITION=AFTER /table marital > sex by happy [ROWPCT.COUNT TOTALS[COUNT]] /CATEGORIES VARIABLES= sex marital happy TOTAL=YES POSITION=AFTER.
===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@... (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Jon Being a complete newbie to CTABLES I’ve been teaching myself by playing with the syntax. When I’ve sorted out what I need I’ll work up some examples using the GUI route as well. I’ve produced a draft tutorial using CTABLES to do the same thing as tutorials 3.1.4.1 to 3.1.4.5 on my site (see http://surveyresearch.weebly.com/31-two-variables-crosstabs.html ). In those I use CROSSTABS, but the output has to be heavily edited. I have to produce the epsilons (percentage differences) manually by copy/pasting tables into Excel, doing the calculations and then copy/pasting the result back into Word underneath the SPSS tables. CTABLES is much better for this, but, unless there’s a facility I haven’t yet found for calculating the value of a cell from the value(s) of others, I still have to use Excel for the epsilons. Zero order tables: ctables   /TABLE sex BY incr3 [ROWPCT.COUNT f5.1 "%" totals [count "n= 100%"]]   /CATEGORIES VARIABLES= incr3 TOTAL=YES    /TABLE workmode BY incr3 [ROWPCT.COUNT f5.1 "%" totals [count "n= 100%"]]   /CATEGORIES VARIABLES= incr3 TOTAL=YES .
The tables above do not have column totals as it's easier to compare the incomes of men/women and full-time/part-time workers without them (and to calculate the percentage point differences, epsilons). I wonder if CTABLES can produce tables with epsilons? For elaboration purposes you need to compare these conditional distributions with the original distribution to see how it has been decomposed. ctables   /TABLE sex BY incr3 [ROWPCT.COUNT f5.1 "%" totals [count "n= 100%"]]   /CATEGORIES VARIABLES= incr3 TOTAL=YES    /TABLE workmode BY incr3 [ROWPCT.COUNT f5.1 "%" totals [count "n= 100%"]]   /CATEGORIES VARIABLES= incr3 TOTAL=YES .
For second order tables (controlling for level of work: blue collar/white collar) it’s easier to work on a subsample (eg people working full time) than to use four variables in a single table. It’s also useful to get the totals in the first row rather than the last: temp. select if workmode = 2. ctables   /VLABELS VARIABLES=sex incr3 class DISPLAY=NONE  /table sex [c] by class [c] > incr3 [c] [ROWPCT.COUNT f8.1 "%" TOTALS[COUNT f8.0 "n= 100%"]]  /CATEGORIES VARIABLES= sex class incr3 TOTAL=YES POSITION=before.
It’s a bit advanced for beginners, but I can use the output without explaining how I got it. I’ve been playing with CTABLES syntax to see what bare minimum is needed (and to teach myself what it can and cannot do) whilst following a logical plan of analysis, using percentages as students can understand those. Once they’ve got their heads round the logic, they might be able to tackle multi-level modelling. Before SPSS took it away, I used to choose a criterion value of the dependent, recode it to 100 and everything else to 0 then use MEANS ~ ~ ~ /CROSSBREAK <depvar> by <indvar> [by <testvar>]. This produced nice little tables in which the “means” were percentages and the counts were the different bases. Made students think when they had to interpret them. John John F Hall (Mr) [Retired academic survey researcher] Email:  [hidden email] Website: www.surveyresearch.weebly.com SPSS start page: www.surveyresearch.weebly.com/1-survey-analysis-workshop From: Jon K Peck [mailto:[hidden email]] I would like to point out, John, that the option for setting the statistics labels is clear if you use the GUI. The same grid where you select the statistics has a column for the label (and a column for the format).
Many thanks for this but first try got an error message:
Took me a moment or two to find the culprit, but I deleted the v in [COUNT v "n= 100%"] . . and it worked perfectly. Did a tweak of my own to hide the name display for sex and got an even better set of tables. Thanks a million. John John F Hall (Mr) [Retired academic survey researcher] Email: [hidden email] Website: www.surveyresearch.weebly.com SPSS start page: www.surveyresearch.weebly.com/1-survey-analysis-workshop (Source: Quality of Life in Britain, 1975)
From: [hidden email] [[hidden email]] On Behalf Of Jignesh Sutar Slight tweak to set the formats of the table cells also: ctables /VLABELS VARIABLES=marital happy DISPLAY=NONE /TABLE sex [c] BY happy [C] [ROWPCT.COUNT f8.1 "%" TOTALS[COUNT f8.0 "n= 100%"]] /CATEGORIES VARIABLES= sex happy TOTAL=YES POSITION=AFTER /TABLE marital [C] BY happy [C] [ROWPCT.COUNT f8.1 "%" TOTALS[COUNT v "n= 100%"]] /CATEGORIES VARIABLES= marital happy TOTAL=YES POSITION=AFTER /table marital > sex by happy [ROWPCT.COUNT f8.1 "%" TOTALS[COUNT f8.0 "n= 100%"]] /CATEGORIES VARIABLES= sex marital happy TOTAL=YES POSITION=AFTER. On 26 September 2014 11:07, Jignesh Sutar <[hidden email]> wrote: ctables /VLABELS VARIABLES=marital happy DISPLAY=NONE /TABLE sex [c] BY happy [C] [ROWPCT.COUNT "%" TOTALS[COUNT "n= 100%"]] /CATEGORIES VARIABLES= sex happy TOTAL=YES POSITION=AFTER /TABLE marital [C] BY happy [C] [ROWPCT.COUNT "%" TOTALS[COUNT "n= 100%"]] /CATEGORIES VARIABLES= marital happy TOTAL=YES POSITION=AFTER /table marital > sex by happy [ROWPCT.COUNT "%" TOTALS[COUNT "n= 100%"]] /CATEGORIES VARIABLES= sex marital happy TOTAL=YES POSITION=AFTER. On 26 September 2014 05:44, John F Hall <[hidden email]> wrote: ctables /TABLE sex [c] BY happy [C] [ROWPCT.COUNT TOTALS[COUNT]] /CATEGORIES VARIABLES= sex happy TOTAL=YES POSITION=AFTER /TABLE marital [C] BY happy [C] [ROWPCT.COUNT TOTALS[COUNT]] /CATEGORIES VARIABLES= marital happy TOTAL=YES POSITION=AFTER /table marital > sex by happy [ROWPCT.COUNT TOTALS[COUNT]] /CATEGORIES VARIABLES= sex marital happy TOTAL=YES POSITION=AFTER. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Free forum by Nabble | Edit this page |