Hi, I am trying to display the value label actual "value" and not the value label name. For example, I have the variable -gender- that is labeled with value label -genderlab2-
I am trying to display only "Female" or "Male". This is part of a larger loop with -putexcel-.
I am showing only one of the variables (-gender-) for the sake of simplicity. There are many more, which makes the loop necessary. The main problem I am trying to overcome is the need for knowing the value label contents for this line of code:
Thanks in advance!
Code:
. label list
genderlab2:
0 Female
1 Male
Code:
foreach x of varlist bc_dm {
local row = 2
foreach var of gender {
putexcel clear
putexcel set results.xlsx, sheet (`x') open modify
ranksum `var', by(`x')
putexcel B`row' = "p =", right
local pval = (r(p_exact))
putexcel C`row' = `pval'
local row = `row'+1
quietly summarize `var' if (`x') == 0, detail
local q50 = r(p50)
putexcel B`row' = "Female median =", right
putexcel C`row'= `q50'
local row = `row'+1
local q25 = r(p25)
putexcel B`row' = "Q25% =", right
putexcel C`row'= `q25'
local row = `row'+1
local q75 = r(p75)
putexcel B`row' = "Q75% =", right
putexcel C`row'= `q75'
local row = `row'+1
quietly summarize `var' if (`x') == 1, detail
local q50 = r(p50)
putexcel B`row' = "Male median =", right
putexcel C`row'= `q50'
local row = `row'+1
local q25 = r(p25)
putexcel B`row' = "Q25% =", right
putexcel C`row'= `q25'
local row = `row'+1
local q75 = r(p75)
putexcel B`row' = "Q75% =", right
putexcel C`row'= `q75'
putexcel save
}
}
Code:
putexcel B`row' = "Female median =", right

Comment