Hi there,
I am using a loop to create a customized table. In the left-most column are variable names. There are three columns of variable medians and a final column of p-values for a comparison of medians. My loop is below. When I run it, however, I get a blank table without entries for the four columns of statistics. I think that there may be a problem with the 'accum' function, but I am not sure. Thanks so much in advance! --Kathryn Overton
Code:
asdoc, row(Indicator, stat1, stat2, stat3, p-Value) title(Comparison of Indicators by Subpopulation) save(Myfile) replace
foreach var of varlist var1-var20 {
local egen m1 = median(`var') if subpopCode==1
asdoc, accum(`m1')
local egen m2 = median(`var') if subpopCode==2
asdoc, accum(`m2')
local egen m3 = median(`var') if subpopCode==3
asdoc, accum(`m3')
median `var', by(subpopCode) medianties(split)
local prob1 : di %9.3f = abs(`r(p)')
if `r(p)' <=0.01 {
local star "***"
}
else if `r(p)' <=0.05{
local star "**"
}
else if `r(p)' <=0.1{
local star "*"
}
else {
local star " "
}
local pstar `prob1'`star'
asdoc, accum(`pstar')
asdoc, row(`var', $accum)
}
I am using a loop to create a customized table. In the left-most column are variable names. There are three columns of variable medians and a final column of p-values for a comparison of medians. My loop is below. When I run it, however, I get a blank table without entries for the four columns of statistics. I think that there may be a problem with the 'accum' function, but I am not sure. Thanks so much in advance! --Kathryn Overton
Code:
asdoc, row(Indicator, stat1, stat2, stat3, p-Value) title(Comparison of Indicators by Subpopulation) save(Myfile) replace
foreach var of varlist var1-var20 {
local egen m1 = median(`var') if subpopCode==1
asdoc, accum(`m1')
local egen m2 = median(`var') if subpopCode==2
asdoc, accum(`m2')
local egen m3 = median(`var') if subpopCode==3
asdoc, accum(`m3')
median `var', by(subpopCode) medianties(split)
local prob1 : di %9.3f = abs(`r(p)')
if `r(p)' <=0.01 {
local star "***"
}
else if `r(p)' <=0.05{
local star "**"
}
else if `r(p)' <=0.1{
local star "*"
}
else {
local star " "
}
local pstar `prob1'`star'
asdoc, accum(`pstar')
asdoc, row(`var', $accum)
}
Comment