2

我有六列: age01 ... age06

它们包含10取决于受访者是否适合该年龄类别。

数据如下: 年龄列

年龄类别是互斥的,被访者不能回答 1 到超过 1,并且至少 1 必须等于 1。

我怎样才能重新编码这样我得到一个变量:

respondent age_category
1   age01
2   age01
3   age04
4   age05
5   age06

一旦我得到这个,下一步就是将这些中的每一个换成一个平均值。IE。年龄 0 -> 24.5。但我可以从上面的格式做到这一点。

4

2 回答 2

2

我怀疑您想要这样的东西(而不是将 AgeCat 编码为您的帖子可能建议的字符串变量):

compute AgeCat= sum(age01*1,age02*2,age03*3,age04*4,age05*5).
value labels AgeCat
  1 "Age Category 1"
  2 "Age Category 2"
  3 "Age Category 3"
  4 "Age Category 4".

在偶然的情况下(通常不是很高的机会),年龄二分法并不相互排斥,我会添加几行额外的代码以进行安全测量,如下所示:

do if sum(age01 to age05)=1.
  compute AgeCat= sum(age01*1,age02*2,age03*3,age04*4,age05*5).
else if sum(age01 to age05)=0.
  compute AgeCat= -98.
else if sum(age01 to age05)>1.
  compute AgeCat= -99.
end if.
value labels AgeCat
  1 "Age Category 1"
  2 "Age Category 2"
  3 "Age Category 3"
  4 "Age Category 4"
  -98 "No data"
  -99 "Multiple entries".
于 2015-10-14T15:09:39.717 回答
2

你可以试试:

string new_age_string (a10).
do repeat a = age01 to age06 / b = 24.5 34.5 44.5 54.5 64.5 74.5 / c = "age_01"  "age_02" "age_03" "age_04" "age_05" "age_06".
if a = 1 new_age = b.
if a = 1 new_age_string = c.
end repeat.
exe.

但是,我认为将年龄重新编码为年龄组的中间值并不明智 - 如果您打算将年龄用作 IV,那么只需将变量重新编码为 1 到 6,您就会得到相同的结果。

于 2015-10-14T15:10:55.623 回答