Skip to content

15.7.1.1 分类变量 ​

命名一个分类变量的轴表达式会按该变量的值将数据划分到各个单元格。当 TABLE 上命名的所有变量都是分类变量时,默认每个单元格显示其包含的个案数,因此只指定一个变量会得到一个频数表,类似于 FREQUENCIES 命令的输出(参见 FREQUENCIES):

CTABLES /TABLE=ageGroup.
Count
Age group15 or younger0
16 to 251099
26 to 35967
36 to 451037
46 to 551175
56 to 651247
66 or older1474

指定一个行分类变量和一个列分类变量会得到一个列联表,类似于 CROSSTABS 命令的输出(参见 CROSSTABS):

CTABLES /TABLE=ageGroup BY gender.
MaleFemale
S3a. GENDER:
CountCount
Age group15 or younger00
16 to 25594505
26 to 35476491
36 to 45489548
46 to 55526649
56 to 65516731
66 or older531943

‘>’“嵌套”运算符将多个变量嵌套在单个轴上,例如:

CTABLES /TABLE likelihoodOfBeingStoppedByPolice BY ageGroup > gender.
YesNo
86. In the past year, have you hosted a social event or party where alcohol was served to adults?
CountCount
Age group15 or youngerS3a. GENDER:Male00
Female00
16 to 25S3a. GENDER:Male208386
Female202303
26 to 35S3a. GENDER:Male225251
Female242249
36 to 45S3a. GENDER:Male223266
Female240307
46 to 55S3a. GENDER:Male201325
Female282366
56 to 65S3a. GENDER:Male196320
Female279452
66 or olderS3a. GENDER:Male162367
Female243700

‘+’“堆叠”运算符允许单个输出表包含多个数据分析。使用 ‘+’ 时,CTABLES 将输出表划分为多个 sections(节),每节都包含对完整数据集的一次分析。例如,以下命令分别按性别对年龄组和驾驶频率制表:

CTABLES /TABLE ageGroup + freqOfDriving BY gender.
MaleFemale
S3a. GENDER:
CountCount
Age group15 or younger00
16 to 25594505
26 to 35476491
36 to 45489548
46 to 55526649
56 to 65516731
66 or older531943
1. How often do you usually drive a car or other motor vehicle?Every day23052362
Several days a week440834
Once a week or less125236
Only certain times a year5872
Never192348

当 ‘+’ 和 ‘>’ 一起使用时,‘>’ 的绑定更紧密。可使用括号覆盖运算符优先级。因此:

CTABLES /TABLE hasConsideredReduction + hasBeenCriticized > gender.
CTABLES /TABLE (hasConsideredReduction + hasBeenCriticized) > gender.
Count
26. During the last 12 months, has there been a time when you felt you should cut down on your drinking?Yes513
No3710
27. During the last 12 months, has there been a time when people criticized your drinking?YesS3a. GENDER:Male135
Female49
NoS3a. GENDER:Male1916
Female2126
Count
26. During the last 12 months, has there been a time when you felt you should cut down on your drinking?YesS3a. GENDER:Male333
Female180
NoS3a. GENDER:Male1719
Female1991
27. During the last 12 months, has there been a time when people criticized your drinking?YesS3a. GENDER:Male135
Female49
NoS3a. GENDER:Male1916
Female2126

基于 GNU PSPP 2.0.1 手册与入门教程整理