Showing posts with label Ctable. Show all posts
Showing posts with label Ctable. Show all posts

Thursday, 13 January 2011

a very simple table using CTables


group Universe vs sample

1 Universe

2 Sample

Total Respondents

Column N %

Count

Column N %

Count

Column N %

Count

1 Female

53.0%

904

61.0%

153

54.0%

1057

2 Male

46.3%

789

39.0%

98

45.3%

887

Not specified

.7%

12

.0%

0

.6%

12


To get the above table use the following syntex:


CTABLES /TABLE gender2 by group [colpct count]
/CATEGORIES VARIABLES=group TOTAL=YES LABEL='Total Respondents'.

&


Main groups

Our big univ

our sample

Total

Column N %

Count

Column N %

Count

Column N %

Count


1 Female

53.0%

904

61.0%

153

54.0%

1057

2 Male

46.3%

789

39.0%

98

45.3%

887

3 Not specified

.7%

12

.0%

0

.6%

12

Total

100.0%

1705

100.0%

251

100.0%

1956


For the above, here is the syntax (notice the columns also have totals now):
CTABLES /TABLE gender2 by group [colpct count]
/CATEGORIES VARIABLES=group TOTAL=YES LABEL='Total Respondents'
/CATEGORIES VARIABLES= gender2 TOTAL=YES POSITION=AFTER.

Thursday, 9 December 2010

Another good table made with CTable

Here is the syntax for the above table:
CTABLES
/TABLE cohort1>( Q11a +Q11b +A11c +Q11d +Q11e +Q11f +Q11g +Q11h +Q11i +Q11j) [COUNT ROWPCT]
/SLABELS VISIBLE=NO
/CLABELS ROWLABELS=OPPOSITE
/CATEGORIES VARIABLES= cohort1 TOTAL=YES LABEL='Total'
/CATEGORIES VARIABLES= Q11a Q11b A11c Q11d Q11e Q11f Q11g Q11h Q11i Q11j TOTAL=YES LABEL='RowTotal'
/TITLE TITLE = 'Q11_: Ranking of abilities by students: (row percents) '+
'by cohort'
CAPTION= 'Report created at )TIME on )DATE' ')TABLE'.

Really nice table

For the above, use this syntax:

CTABLES
/TABLE (Q11a +Q11b +A11c +Q11d +Q11e +Q11f +Q11g +Q11h +Q11i +Q11j) [COLPCT] [COUNT] BY cohort1
/SLABELS VISIBLE=NO
/CATEGORIES VARIABLES=cohort1 TOTAL=YES LABEL='Total Respondents'
/CATEGORIES VARIABLES= Q11a Q11b A11c Q11d Q11e Q11f Q11g Q11h Q11i Q11j [1, 2, 3, 4, SUBTOTAL, OTHERNM] EMPTY=INCLUDE POSITION=AFTER.
/TITLE TITLE = 'Ranking of abilities by students '+
'by cohort'
CAPTION= 'Report created at )TIME on )DATE' ')TABLE'.

Wednesday, 8 December 2010

More CTable commands in Syntax

% in columns and Ns is col after it.
CTABLES /TABLE NEWS [COUNT COLPCT] /SLABELS POSITION=ROW VISIBLE=NO.


Or the same thing but the Ns in rows instead of a separate column.

CTABLES /TABLE NEWS [COUNT COLPCT].

CTABLES /TABLE (CONFINAN + CONBUS + CONBUS + CONEDUC + CONPRESS + CONMEDIC)[COUNT ROWPCT] /CLABELS ROWLABELS=OPPOSITE.

CTABLES /TABLE $MLTNEWS [COUNT COLPCT] BY SEX /SLABELS VISIBLE=NO /CATEGORIES VARIABLES=SEX TOTAL=YES.

CTABLES /TABLE POLVIEWS [COLPCT] BY AGECAT.


CTABLES /TABLE (CONFINAN + CONEDUC + CONBUS + CONMEDIC + CONPRESS + CONTV ) /SLABELS VISIBLE=NO /CLABELS ROWLABELS=OPPOSITE

OR

CTABLES /TABLE (CONFINAN + CONEDUC + CONBUS + CONMEDIC + CONPRESS + CONTV )

To add "Totals"

CTABLES /TABLE AGECAT
/CATEGORIES VARIABLES=AGECAT TOTAL=YES LABEL='Total Respondents'.
/TABLE SEX [COUNT] + HAPPY [COUNT, COLPCT] /TABLE (SEX + HAPPY [COLPCT])[COUNT]

Tuesday, 7 December 2010

Nesting in CTABLE and sorted results

example 1:
CTABLES /TABLE SEX > HAPMAR [COLPCT] BY CHILDCAT.

example 2:
CTABLES /TABLE SEX > HAPMAR BY CHILDCAT.
OR
CTABLES /TABLE (HAPPY + HAPMAR) > SEX.

choose one of the above depending on how you want the variable SEX
to be displayed the first example brings it out as the outer most variable,
while the 2nd one puts it as the inner most.


The following will give sorted result (Descending) based on
the variable CAR1 by age group
of respondent:

CTABLES
/TABLE CAR1 BY AGECAT
/CATEGORIES VARIABLES=AGECAT TOTAL=YES
/CATEGORIES VARIABLES=CAR1 ORDER=D KEY=COUNT.


(Source SPSS help file)

*In addition to the above, I want to add column percents
and Ns to the tables!!