提问人:maldini425 提问时间:12/12/2020 最后编辑:Nick Coxmaldini425 更新时间:12/12/2020 访问量:127
从宽到长重塑
Reshaping Wide to Long
问:
我的数据目前在 Stata 中组织如下:
iso_code indicator value
ALB Share of employees in agriculture (% of total employees) 2.52084
ARG Employment in agriculture 11.153
ARG Share of employees in agriculture (% of total employees) .104509
AUS Employment in agriculture 329.66
AUS Share of employees in agriculture (% of total employees) 1.47018
AUT Employment in agriculture 159.549
AUT Employment-to-population ratio, rural areas 60.4239
AUT Labour force participation rate, rural areas 61.9622
AUT Share of employees in agriculture (% of total employees) .838354
AZE Employment in agriculture 1769.3
我希望每个国家/地区都在一行中,然后变量名称及其值作为单独的列。
iso_code Employment in agriculture Share of employees in agriculture (% of total employees)
AUT 159.549 .838354
我尝试了以下代码,但不断收到此错误:“indicator.1720000058412552 无效的变量名称”
reshape wide indicator value, i(iso_code) j(value)
答:
1赞
maldini425
12/12/2020
#1
使用以下代码解决了该问题:
// Converting the "indicator" variable into numeric to reshape the dataset
encode indicator, gen(indicator_numeric)
// Reshape long to wide
reshape wide indicator value, i(iso_code) j(indicator_numeric)
评论