0
votes

My data is currently organized in Stata as follows:

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

And I would like each country to be in one row, and then the variable names and their values as separate columns.

iso_code      Employment in agriculture   Share of employees in agriculture (% of total employees) 
AUT             159.549                        .838354

I have tried the following code, but I keep getting this error: "indicator.1720000058412552 invalid variable name"

reshape wide indicator value, i(iso_code)  j(value)
1

1 Answers

1
votes

Solved the problem with the following code:

// 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)