使用2个其他变量在SPSS中创建变量?

时间:2013-10-10 20:21:18

标签: variables spss

所以,我一直在使用SPSS的时间不长,我需要帮助使用其他两个创建变量。

我有一个调查,每个人的“家庭号码”变量和“与家长关系”的另一个变量(头= 1,配偶= 2,孩子= 3等)。 我想通过与每个家庭中与户主的关系来创建“家庭类型”的变量。

所以,比如:

If in the household there's only the head, then is 1
If there's the head, spouse and/or children, then is 2
If it's head plus any other type of relative, it's 3.

例如:

  

家庭Nº - 关系

     

1 - 1

     

1 - 2

     

1 - 3

在家庭“1”中有头(1),配偶(2)和孩子(3),因此它将是“家庭类型”2。

我不知道用于执行此操作的命令是SPPS。任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:1)

我怀疑这需要使用AGGREGATE为所有家庭成员分配所需的特征,然后使用if语句来制作家庭类型。因此,让我们从类似于您的示例数据开始。这使得一组家庭成为长格式。

data list free / house relation.
begin data
1 1
1 2
1 3
2 1
3 1
3 2
4 1
4 3
5 1
5 2
5 3
5 3
5 3
end data.
VALUE LABELS relation
1 'Head'
2 'Spouse'
3 'Child'.

从这里我会建议四种类型的家庭; Single-No ChildrenCouple-No ChildrenSingle-With ChildrenCouple-With Children。为了得到这些,我制作一个虚拟变量来表明案件是儿童还是配偶,然后汇总家庭中的最小值,以便为家庭中是否有任何配偶或任何子女提供标志。

*Make flag for if have a spouse and if have a child.
COMPUTE child = (relation EQ 3).
COMPUTE spouse = (relation EQ 2).
*Aggregate to get a flag for child or spouse.
AGGREGATE
  /OUTFILE=* MODE=ADDVARIABLES
  /BREAK=house
  /AnyChild = MAX(child) 
  /AnySpouse = MAX(spouse)
  /NumChild=SUM(child)
  /TotalFamSize=N.

我还展示了如何使用SUM获取使用N的子项的总数以及使用*From here can make several fam categories using DO IF. DO IF TotalFamSize = 1. COMPUTE FamType = 1. ELSE IF AnySpouse = 1 AND AnyChild = 0. COMPUTE FamType = 2. ELSE IF AnySpouse = 0 and AnyChild = 1. COMPUTE FamType = 3. ELSE IF AnySpouse = 1 and AnyChild = 1. COMPUTE FamType = 4. END IF. VALUE LABELS FamType 1 'Single - No Children' 2 'Couple - No Children' 3 'Single - Children' 4 'Couple - Children'. EXECUTE. 中的总族数。从这里,您可以使用一系列if语句对不同类型的族进行分类。

{{1}}

使用聚合来获取整个家庭的统计数据的逻辑应该适用于您想要生成的任何类型的统计数据。

相关问题