【发布时间】:2023-03-16 06:41:02
【问题描述】:
我在 Stata 中有如下所示的数据集
entityID indicator indicatordescr indicatorvalue
1 gdp Gross Domestic 100
1 pop Population 15
1 area Area 50
2 gdp Gross Domestic 200
2 pop Population 10
2 area Area 300
indicator 的值和indicatordescr 的值之间存在一对一的映射关系。
我想把它改成宽的,即:
entityID gdp pop area
1 100 15 50
2 200 10 300
我希望gdp 变量标签为“国内生产总值”、pop 标签“人口”和area“面积”。
不幸的是,据我了解,无法将indicatordescr 的值分配为indicator 的值标签,因此reshape 无法将这些值标签转换为变量标签。
我看过这个:Bring value labels to variable labels when reshaping wide
还有这个:http://www.stata.com/support/faqs/data-management/apply-labels-after-reshape/
但不明白如何将这些应用到我的案例中。
注意:reshape 后的变量标记必须以编程方式完成,因为indicator 和indicatordescr 有很多值。
【问题讨论】: