Hi
I am using Stata 13.1 for Windows. I have a dataset with 402 numerical and string variables whose names are shorthand for what they represent. I have listed some of the variable names below:
bl_el_cnst_cst
bl_mnt_cnst_cst
bl_ov_cnst_cst
st_cv_cnst_cst
st_el_cnst_cst
bl_el_cond
bl_mnt_cond
bl_ov_cond
I would like to label them using a loop, such that all variables that end in _cnst_cst have "construction cost" as the last two words of their label; all those ending with _cond would have "condition" as the last two words of their label.
All variables that start with bl_el have "building electrical" as the first two words of their label; those that start with bl_mnt have "building maintenance as the first two words of the label; those that start with bl_ov have "building overall" as the first words of the label etc.
So the variables would be labeled as follows:
bl_el_cnst_cst "building electrical construction cost"
bl_mnt_cnst_cst "building maintenance construction cost"
bl_ov_cnst_cst "building overall construction cost"
st_cv_cnst_cst "site civil construction cost"
st_el_cnst_cst "site electrical construction cost"
bl_el_cond "building electrical condition"
bl_mnt_cond "building maintenance condition"
bl_ov_cond "building overall condition"
I'm trying the following code, but I think add and modify are only for label define rather than label var:
foreach var of varlist bl_el* {
label var `var' "building electrical"
}
foreach var of varlist *_cnst_cst {
label var `var' "construction cost", add
}
Any help would be greatly appreciated. Thanks
Megan
I am using Stata 13.1 for Windows. I have a dataset with 402 numerical and string variables whose names are shorthand for what they represent. I have listed some of the variable names below:
bl_el_cnst_cst
bl_mnt_cnst_cst
bl_ov_cnst_cst
st_cv_cnst_cst
st_el_cnst_cst
bl_el_cond
bl_mnt_cond
bl_ov_cond
I would like to label them using a loop, such that all variables that end in _cnst_cst have "construction cost" as the last two words of their label; all those ending with _cond would have "condition" as the last two words of their label.
All variables that start with bl_el have "building electrical" as the first two words of their label; those that start with bl_mnt have "building maintenance as the first two words of the label; those that start with bl_ov have "building overall" as the first words of the label etc.
So the variables would be labeled as follows:
bl_el_cnst_cst "building electrical construction cost"
bl_mnt_cnst_cst "building maintenance construction cost"
bl_ov_cnst_cst "building overall construction cost"
st_cv_cnst_cst "site civil construction cost"
st_el_cnst_cst "site electrical construction cost"
bl_el_cond "building electrical condition"
bl_mnt_cond "building maintenance condition"
bl_ov_cond "building overall condition"
I'm trying the following code, but I think add and modify are only for label define rather than label var:
foreach var of varlist bl_el* {
label var `var' "building electrical"
}
foreach var of varlist *_cnst_cst {
label var `var' "construction cost", add
}
Any help would be greatly appreciated. Thanks
Megan
Comment