Dear all,
I am struggling with the following problem:
I have several datasets I want to append, but the variable names differ from one dataset to the next.
My variables are called very uniformative v1 to v300 and the information is caught in the lables, e.g. v1 ~ "Interviewdate". I would like to rename all variables by its label, but do not find the right command.
I have found the following loop, but I am not sure how to adapt the variable names:
foreach v of varlist _all{
local x= variable label `v'
rename `v' `x'
}
, but STATA tells me "variable not found". If I drop the word "variable", it tells me "label not found".
Could anybody tell me how to define it better, that it works for my case?
I would be really happy!
Best
Nadine
I am struggling with the following problem:
I have several datasets I want to append, but the variable names differ from one dataset to the next.
My variables are called very uniformative v1 to v300 and the information is caught in the lables, e.g. v1 ~ "Interviewdate". I would like to rename all variables by its label, but do not find the right command.
I have found the following loop, but I am not sure how to adapt the variable names:
foreach v of varlist _all{
local x= variable label `v'
rename `v' `x'
}
, but STATA tells me "variable not found". If I drop the word "variable", it tells me "label not found".
Could anybody tell me how to define it better, that it works for my case?
I would be really happy!
Best
Nadine
Comment