Alejandro Viete
Alejandro Viete

Reputation: 1

How to append datasets with same variable names but different numeric values within?

I am having difficulty appending datasets from multiple different years. I have made sure that the variable names are the same across the different datasets. However, within the numeric variables, the labelling is different--so that in one data set Catholic=1 but in another one Catholic=11. This causes the data to get messed up when appending. Is there a fix for this?

Upvotes: 0

Views: 501

Answers (1)

Jonathan Old
Jonathan Old

Reputation: 311

Here is a short snippet which you can use to decode all variables with value labels:

ds, has(vallabel)

foreach var in `r(varlist)' {
decode `var', gen(`var'x)
drop `var'
ren `var'x `var'
}

Upvotes: 1

Related Questions