Hello everyone, I have a question about the use of variable labels.
Scenario:
Looking at the code below, you will notice that I am writing a variables name in a text.file if its value is greater than 0. However, instead of the variables name (`var'), I want to write down its label. How can I achieve this? Thank you for the help.
Code:
file open keywords using `file_title'.txt, text write replace
local N = _N
forvalues i = 1 / `N' {
file write keywords _n
file write keywords _n
file write keywords "Article: `= pdf_name[`i']'" _n
file write keywords _n
file write keywords "Keywords:" _n
foreach var of varlist `var_list' {
if `var'[`i'] > 0 {
file write keywords "`var'" _n
}
else if `var'[`i'] == 0 {
}
}
}
file close keywords
Scenario:
Looking at the code below, you will notice that I am writing a variables name in a text.file if its value is greater than 0. However, instead of the variables name (`var'), I want to write down its label. How can I achieve this? Thank you for the help.
Code:
file open keywords using `file_title'.txt, text write replace
local N = _N
forvalues i = 1 / `N' {
file write keywords _n
file write keywords _n
file write keywords "Article: `= pdf_name[`i']'" _n
file write keywords _n
file write keywords "Keywords:" _n
foreach var of varlist `var_list' {
if `var'[`i'] > 0 {
file write keywords "`var'" _n
}
else if `var'[`i'] == 0 {
}
}
}
file close keywords
Comment