Hi all, I am new to the forum, and I appreciate your kind help in advance.
I am currently in the process of replicating a paper. Here is the code:
capture program drop generate_labeled_var
program generate_labeled_var
syntax, yvar(string)
capture gen T_`yvar' = T
local label: variable label `yvar'
label var T_`yvar' "`label'"
end
foreach yvar in eq_index_mh_all {
generate_labeled_var, yvar(`yvar')
}
Could someone help explain what the code is doing? it defines a function generate_label_var and use syntax to fit in. but what is yvar(string) doing? and how to understand T_`yvar' = T ?
Thanks a lot
I am currently in the process of replicating a paper. Here is the code:
capture program drop generate_labeled_var
program generate_labeled_var
syntax, yvar(string)
capture gen T_`yvar' = T
local label: variable label `yvar'
label var T_`yvar' "`label'"
end
foreach yvar in eq_index_mh_all {
generate_labeled_var, yvar(`yvar')
}
Could someone help explain what the code is doing? it defines a function generate_label_var and use syntax to fit in. but what is yvar(string) doing? and how to understand T_`yvar' = T ?
Thanks a lot

Comment