我有这样的数据:
Person Region Grapes Apples Bananas
Bob IV 4 2 1
Jane II 0 1 2
我需要重组(vars to cases?)以返回该人拥有的每个水果的一条记录,如下所示:
Person Region Fruit
Bob IV Grapes
Bob IV Grapes
Bob IV Grapes
Bob IV Grapes
Bob IV Apples
Bob IV Apples
Bob IV Bananas
Jane II Apples
Jane II Bananas
Jane II Bananas
下面的代码将返回此代码,这是更接近但不完全的步骤:
Person Region Fruit Count
Bob IV Grapes 4
Bob IV Apples 2
Bob IV Bananas 1
Jane II Apples 1
Jane II Bananas 2
VARSTOCASES
/MAKE Count FROM Grapes Apples Bananas
/INDEX=Fruit(Count)
/KEEP=Person Region
/NULL=KEEP.
有什么建议吗?
答案 0 :(得分:2)
是的,这是代码的第一步!接下来,只需添加这篇文章:
loop # = 1 to Count.
xsave outfile = 'c:/personal/disaggregated.sav' / drop count.
end loop.
这就是您所需要的一切 - 它将根据您的Count
变量循环并重复这些值。
干杯, 瓦莱里娅