I am using collect to create a simple table of proportions using a stacked layout where confidence intervals (CIs) are placed on a separate row below the proportions. I'd like to retain the "95% CI" row when the proportion is zero and include a placeholder like "NA" for the CIs. However, the default behavior shown in Example 1 is for Stata to drop the unused CI row.
For the horizontal layout in Example 2 I used collect style cell, empty(NA) to replace the missing CIs with NA. Unfortunately, this option has no effect on the stacked layout, nor does collect style showempty on. I'd appreciate any advice on how to retain the CI row and insert a placeholder like "NA" for the stacked layout in Example 1.
I am using StataNow/MP 19.5 for Windows.
For the horizontal layout in Example 2 I used collect style cell, empty(NA) to replace the missing CIs with NA. Unfortunately, this option has no effect on the stacked layout, nor does collect style showempty on. I'd appreciate any advice on how to retain the CI row and insert a placeholder like "NA" for the stacked layout in Example 1.
I am using StataNow/MP 19.5 for Windows.
Code:
clear all
set obs 50
* Binary Dependent Variable
gen depvar = round(runiform())
* 5-Category Independent Variable
gen indvar = round(runiform() * 4) + 1
* Replace Dependent Variable = 0 for 1st Category of Independent Variable
replace depvar = 0 if indvar == 1
* Collect Results from Proportion
collect clear
collect: prop depvar, over(indvar)
* Empty Cells as NA
collect style cell, empty("NA")
collect style showempty on
* Example 1: No Confidence Interval Row Displayed for 0 Proportion
collect layout (colname#result[_r_b _r_ci])
* Example 2: Confidence Intervals Showing NA as Desired
collect layout (colname) (result[_r_b _r_ci])

Comment