I am trying to create an automated output table for the results of a Cox model and would like to replace the p-values (_r_p) for each level of a categorical variable with the single p-value obtained using the testparm command.
This is some of the code I have drafted so far but I can't seem to swap the p-values:
collect _r_b _r_ci _r_p, ///
name(MyModels) ///
tag(model[(1)] colname[1.age]) ///
: stcox age
collect get _r_b _r_ci, ///
name(MyModels) ///
tag(model[(1)]) ///
: stcox i.age_gp
collect get r(p), tag(model[(1)] colname[(age_gp)] ) : testparm i.age_gp
collect _r_b _r_ci _r_p, ///
name(MyModels) ///
tag(model[(1)]) ///
: stcox sex
collect layout (colname) (result[_r_b _r_ci _r_p]) (model[(1)]), name(MyModels)
collect style row stack, spacer delimiter(" x ")
collect style cell, nformat(%5.2f)
collect style cell result[_r_p], nformat(%5.3f) minimum(0.001)
collect style cell result[_r_ci], sformat("(%s)") cidelimiter(,)
collect style cell cell_type[item column-header], halign(center)
Any advice would be greatly appreciated.
This is some of the code I have drafted so far but I can't seem to swap the p-values:
collect _r_b _r_ci _r_p, ///
name(MyModels) ///
tag(model[(1)] colname[1.age]) ///
: stcox age
collect get _r_b _r_ci, ///
name(MyModels) ///
tag(model[(1)]) ///
: stcox i.age_gp
collect get r(p), tag(model[(1)] colname[(age_gp)] ) : testparm i.age_gp
collect _r_b _r_ci _r_p, ///
name(MyModels) ///
tag(model[(1)]) ///
: stcox sex
collect layout (colname) (result[_r_b _r_ci _r_p]) (model[(1)]), name(MyModels)
collect style row stack, spacer delimiter(" x ")
collect style cell, nformat(%5.2f)
collect style cell result[_r_p], nformat(%5.3f) minimum(0.001)
collect style cell result[_r_ci], sformat("(%s)") cidelimiter(,)
collect style cell cell_type[item column-header], halign(center)
Any advice would be greatly appreciated.
Comment