Hello all,
I managed to create a uni-variate and multi-variate table of HR and CI for several Cox models with a HR and CI column for each of the uni- and multivariable models. I needed to include the N in each model as a third column for each of these preceding the HR column. Somehow, my -collect- code does not seems to be collecting this N. I am confused if this is e(N) or N that I supposed to collect. Neither of them seem to work with collecting and adding the N columns
What am I doing wrong with this code? Glad to -dataex- if that would help.
I managed to create a uni-variate and multi-variate table of HR and CI for several Cox models with a HR and CI column for each of the uni- and multivariable models. I needed to include the N in each model as a third column for each of these preceding the HR column. Somehow, my -collect- code does not seems to be collecting this N. I am confused if this is e(N) or N that I supposed to collect. Neither of them seem to work with collecting and adding the N columns
What am I doing wrong with this code? Glad to -dataex- if that would help.
Code:
collect clear
local whatineed "e(N) _r_b _r_ci"
collect create mv1
collect `whatineed': stcox i.age70 i.ea74
collect `whatineed': stcox i.age70
collect `whatineed': stcox i.ea74
collect `whatineed': stcox i.anymds
collect `whatineed': stcox i.rmono
collect `whatineed': stcox i.del5
collect `whatineed': stcox i.loss17
collect `whatineed': stcox i.kar50
collect `whatineed': stcox i.top10
collect `whatineed': stcox i.smotl1
collect `whatineed': stcox i.revel95
collect `whatineed': stcox i.bayes55
collect style showbase all
// Number formatting
collect style cell, nformat(%5.2f)
collect style cell result[_r_ci], sformat("[%s]") cidelimiter(", ")
collect style cell border_block, border(right, pattern(nil))
collect style cell result[N], nformat(%4.0f)
//Var and label name formatting
collect stars _r_p 0.01 "***" 0.05 "** " 0.1 "* " 1 " ", attach(_r_b)
collect notes : "*** p<.01, ** p<.05, * p<.1"
collect style cell result[_r_b], halign(left) margin(left, width(10))
collect style row stack, nobinder // indents the factor from variable name
collect levels cmdset
collect addtags uvmodel[2], fortags(cmdset[2 3 4 5 6 7 8 9 10 11 12]) // tags univariate to 1 column
collect addtags uvmodel[1], fortags(cmdset[1])
collect levelsof uvmodel
collect layout (colname)(uvmodel#result)
//Align CI to the left and relabel some
collect style cell result[_r_ci], halign(center)
collect style cell result[_r_b], halign(left)
collect style cell result[N], halign(center)
collect label levels uvmodel 1 "Multi-variable" 2 "Uni-variable"
collect label levels age70 0 "<=70 yrs" 1 ">70 yrs", modify
collect label levels monomore 0 "0-1" 1 "2+", modify
collect label dim age70 "Age at Dx.", modify
collect label levels result _r_b "HR", modify
collect label levels result _r_ci "95% CI", modify
collect label levels result N "Total", modify
collect style column, dups(center) extraspace(2) width(equal)
collect preview