Column headers and cell formats in CTABLES

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Column headers and cell formats in CTABLES

John F Hall

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.

 

 

 

happy

Not too happy

Fairly Happy

Very happy

Total

Row N %

Row N %

Row N %

Count

sex

Men

6.2%

59.7%

34.0%

385

Women

6.1%

52.9%

41.0%

541

Total

6.2%

55.7%

38.1%

926

 

 

 

happy

Not too happy

Fairly Happy

Very happy

Total

Row N %

Row N %

Row N %

Count

marital

Single

4.7%

70.0%

25.3%

150

Married

4.5%

51.9%

43.6%

649

Widowed

17.3%

59.2%

23.5%

98

Divorced or separated

13.8%

55.2%

31.0%

29

Total

6.2%

55.7%

38.1%

926

 

 

 

happy

Not too happy

Fairly Happy

Very happy

Total

Row N %

Row N %

Row N %

Count

marital

Single

sex

Men

5.3%

75.0%

19.7%

76

Women

4.1%

64.9%

31.1%

74

Total

4.7%

70.0%

25.3%

150

Married

sex

Men

5.2%

55.6%

39.2%

288

Women

3.9%

49.0%

47.1%

361

Total

4.5%

51.9%

43.6%

649

Widowed

sex

Men

26.7%

60.0%

13.3%

15

Women

15.7%

59.0%

25.3%

83

Total

17.3%

59.2%

23.5%

98

Divorced or separated

sex

Men

16.7%

66.7%

16.7%

6

Women

13.0%

52.2%

34.8%

23

Total

13.8%

55.2%

31.0%

29

Total

sex

Men

6.2%

59.7%

34.0%

385

Women

6.1%

52.9%

41.0%

541

Total

6.2%

55.7%

38.1%

926

 

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:

 

 

happy

Not too happy

Fairly Happy

Very happy

Total

%

%

%

n = 100%

marital

Single

4.7

70.0

25.3

150

Married

4.5

51.9

43.6

649

Widowed

17.3

59.2

23.5

98

Divorced or separated

13.8

55.2

31.0

29

Total

6.2

55.7

38.1

926

 

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)?

 

 

 

Not too happy

Fairly Happy

Very happy

Total

%

%

%

n = 100%

 

Single

4.7

70.0

25.3

150

Married

4.5

51.9

43.6

649

Widowed

17.3

59.2

23.5

98

Divorced or separated

13.8

55.2

31.0

29

Total

6.2

55.7

38.1

926

 

 

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

 

 

 

===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: Column headers and cell formats in CTABLES

Jignesh Sutar

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
Reply | Threaded
Open this post in threaded view
|

Re: Column headers and cell formats in CTABLES

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
Reply | Threaded
Open this post in threaded view
|

Re: Column headers and cell formats in CTABLES

John F Hall

Jignesh

 

Many thanks for this but first try got an error message:

 

Warnings

TABLE: Text v. An invalid subcommand, keyword, or option was specified.

Execution of this command stops.

 

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) 

 

 

Not too happy

Fairly Happy

Very happy

Total

%

%

%

n= 100%

Men

6.2

59.7

34.0

385

Women

6.1

52.9

41.0

541

Total

6.2

55.7

38.1

926

 

 

Not too happy

Fairly Happy

Very happy

Total

%

%

%

n= 100%

Single

4.7

70.0

25.3

150

Married

4.5

51.9

43.6

649

Widowed

17.3

59.2

23.5

98

Divorced or separated

13.8

55.2

31.0

29

Total

6.2

55.7

38.1

926

 

 

Not too happy

Fairly Happy

Very happy

Total

%

%

%

n= 100%

Single

Men

5.3

75.0

19.7

76

Women

4.1

64.9

31.1

74

Total

4.7

70.0

25.3

150

Married

Men

5.2

55.6

39.2

288

Women

3.9

49.0

47.1

361

Total

4.5

51.9

43.6

649

Widowed

Men

26.7

60.0

13.3

15

Women

15.7

59.0

25.3

83

Total

17.3

59.2

23.5

98

Divorced or separated

Men

16.7

66.7

16.7

6

Women

13.0

52.2

34.8

23

Total

13.8

55.2

31.0

29

Total

Men

6.2

59.7

34.0

385

Women

6.1

52.9

41.0

541

Total

6.2

55.7

38.1

926

 

 

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Jignesh Sutar
Sent: 26 September 2014 12:12
To: John F Hall
Cc: [hidden email]
Subject: Re: Column headers and cell formats in CTABLES

 

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
Reply | Threaded
Open this post in threaded view
|

Re: Column headers and cell formats in CTABLES

Jon K Peck
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:

 

Warnings
TABLE: Text v. An invalid subcommand, keyword, or option was specified.
Execution of this command stops.

 

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) 

 

 
Not too happy
Fairly Happy
Very happy
Total
%
%
%
n= 100%
Men
6.2
59.7
34.0
385
Women
6.1
52.9
41.0
541
Total
6.2
55.7
38.1
926

 

 
Not too happy
Fairly Happy
Very happy
Total
%
%
%
n= 100%
Single
4.7
70.0
25.3
150
Married
4.5
51.9
43.6
649
Widowed
17.3
59.2
23.5
98
Divorced or separated
13.8
55.2
31.0
29
Total
6.2
55.7
38.1
926

 

 
Not too happy
Fairly Happy
Very happy
Total
%
%
%
n= 100%
Single Men
5.3
75.0
19.7
76
Women
4.1
64.9
31.1
74
Total
4.7
70.0
25.3
150
Married Men
5.2
55.6
39.2
288
Women
3.9
49.0
47.1
361
Total
4.5
51.9
43.6
649
Widowed Men
26.7
60.0
13.3
15
Women
15.7
59.0
25.3
83
Total
17.3
59.2
23.5
98
Divorced or separated Men
16.7
66.7
16.7
6
Women
13.0
52.2
34.8
23
Total
13.8
55.2
31.0
29
Total Men
6.2
59.7
34.0
385
Women
6.1
52.9
41.0
541
Total
6.2
55.7
38.1
926

 

 

 

From: [hidden email] [mailto:jignesh.sutar@...] On Behalf Of Jignesh Sutar
Sent:
26 September 2014 12:12
To:
John F Hall
Cc:
[hidden email]
Subject:
Re: Column headers and cell formats in CTABLES

 

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

Reply | Threaded
Open this post in threaded view
|

Re: Column headers and cell formats in CTABLES

John F Hall

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 .

 

 

Q918b  Gross income of R (if working)

[3 groups]

<£6000

<£12000

<£12000+

Total

%

%

%

n= 100%

Q901a: Sex of respondent

Men

9.8

41.4

48.7

874

Women

55.8

33.7

10.5

686

 

Epsilon

-46.0

7.7

38.2

 

 

Q918b  Gross income of R (if working)

[3 groups]

<£6000

<£12000

<£12000+

Total

%

%

%

n= 100%

Mode of work

Parttime

86.5

10.4

3.0

297

Fulltime

16.8

44.5

38.7

1263

 

Epsilon

69.7

-34.1

-35.7

 

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 .

 

 

Q918b  Gross income of R (if working) [3 groups]

<£6000

<£12000

<£12000+

Total

%

%

%

n= 100%

Q901a: Sex of respondent

Men

9.8

41.4

48.7

874

Women

55.8

33.7

10.5

686

Total

30.1

38.0

31.9

1560

 

 

 

Q918b  Gross income of R (if working) [3 groups]

<£6000

<£12000

<£12000+

Total

%

%

%

n= 100%

Mode of work

Parttime

86.5

10.4

3.0

297

Fulltime

16.8

44.5

38.7

1263

Total

30.1

38.0

31.9

1560

 

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.

 

 

 

Total

Non-manual

Manual

Total

<£6000

<£12000

<£12000+

Total

<£6000

<£12000

<£12000+

Total

<£6000

<£12000

<£12000+

n= 100%

%

%

%

n= 100%

%

%

%

n= 100%

%

%

%

Total

1242

16.8

44.4

38.7

699

12.6

38.2

49.2

543

22.3

52.5

25.2

Men

834

8.6

41.8

49.5

401

5.0

26.2

68.8

433

12.0

56.4

31.6

Women

408

33.6

49.8

16.7

298

22.8

54.4

22.8

110

62.7

37.3

.0

 

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]]
Sent: 26 September 2014 14:34
To: John F Hall
Cc: [hidden email]
Subject: Re: [SPSSX-L] Column headers and cell formats in CTABLES

 

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:

 

Warnings

TABLE: Text v. An invalid subcommand, keyword, or option was specified.

Execution of this command stops.

 

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) 

 

 

Not too happy

Fairly Happy

Very happy

Total

%

%

%

n= 100%

Men

6.2

59.7

34.0

385

Women

6.1

52.9

41.0

541

Total

6.2

55.7

38.1

926

 

 

Not too happy

Fairly Happy

Very happy

Total

%

%

%

n= 100%

Single

4.7

70.0

25.3

150

Married

4.5

51.9

43.6

649

Widowed

17.3

59.2

23.5

98

Divorced or separated

13.8

55.2

31.0

29

Total

6.2

55.7

38.1

926

 

 

Not too happy

Fairly Happy

Very happy

Total

%

%

%

n= 100%

Single

Men

5.3

75.0

19.7

76

Women

4.1

64.9

31.1

74

Total

4.7

70.0

25.3

150

Married

Men

5.2

55.6

39.2

288

Women

3.9

49.0

47.1

361

Total

4.5

51.9

43.6

649

Widowed

Men

26.7

60.0

13.3

15

Women

15.7

59.0

25.3

83

Total

17.3

59.2

23.5

98

Divorced or separated

Men

16.7

66.7

16.7

6

Women

13.0

52.2

34.8

23

Total

13.8

55.2

31.0

29

Total

Men

6.2

59.7

34.0

385

Women

6.1

52.9

41.0

541

Total

6.2

55.7

38.1

926

 

 

 

From: [hidden email] [[hidden email]] On Behalf Of Jignesh Sutar
Sent:
26 September 2014 12:12
To:
John F Hall
Cc:
[hidden email]
Subject:
Re: Column headers and cell formats in CTABLES

 

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

===================== 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