Hi,

I am using the excellent Example 3 in the "Stata Customizable Tables" manual to help me build a table with frequency (percent) for categorical variables, and mean (sd) for continuous variables. Some of my continuous variables are, however, very skewed (age data for infants). For those variables I would like to report age in months as median (IQR). I would like to format the IQR as (p25 – p75). I think that what I need to do is combine both p25 and p75 into a single level of the dimension result, but I'm not sure how to do that.

I am aware that
Code:
table1_mc
does this. I have used and loved table1_mc, but I really want to learn the collect system.

For this post, below are data for age in months and sex. What I'm after is:
Male Female
Age (months) median (p25 – p75) median (p25 – p75)
Here are my data for sex and age (months):

----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input float age_adm_m byte sex
15.342916 1
 54.80082 1
 19.74538 1
75.663246 1
 19.81109 1
 46.45585 1
 32.29569 1
3.3839836 2
 67.15401 2
14.554415 1
69.650925 2
 83.58111 1
15.014374 1
 46.75154 2
36.172485 1
35.876797 1
 7.096509 1
 39.85216 1
 7.523614 1
  43.6961 1
  3.12115 1
 36.99384 2
 55.78645 2
 30.12731 2
 52.46817 2
 3.613963 1
 17.87269 2
31.507187 2
 30.58727 1
18.431211 1
 43.63039 2
15.967146 2
  50.7269 1
32.492813 2
16.689938 1
 18.89117 1
 30.45585 2
 3.581109 2
19.876797 1
 82.95688 1
 71.29363 2
  62.0616 2
 30.45585 1
 51.44969 2
 14.52156 2
11.498973 1
1.4784395 2
 28.64887 2
 51.58111 1
 72.24641 2
31.802876 1
 42.48049 1
2.1026695 2
 127.5729 1
 40.21355 2
 8.936345 1
 3.876797 2
30.390144 1
 44.71458 2
 11.17043 1
 10.61191 1
 39.09651 1
 14.52156 2
 78.91581 1
16.328543 1
 42.21766 1
11.039015 1
 80.16427 1
150.70226 2
 3.022587 1
 59.07187 1
 38.40657 1
 57.49487 1
 59.00616 2
 19.58111 2
 2.792608 2
 79.50719 2
122.71047 2
 92.09035 1
 2.562628 2
 46.02875 1
 95.77002 2
 34.49692 2
 6.702259 1
       48 2
 43.13758 2
125.40452 2
        . 1
 76.38604 1
11.334702 1
 43.23614 1
 59.59753 1
 55.88501 1
 6.537988 1
 82.16838 1
 43.00616 1
 54.17659 2
 25.23203 1
  54.2423 1
 17.87269 1
end
label values sex sex_lbl
label def sex_lbl 1 "Male", modify
label def sex_lbl 2 "Female", modify
------------------ copy up to and including the previous line ------------------


Here is my code for what I'm after using mean and SD:

Code:
table (var) (shortsite), statistic(fvfrequency sex) statistic(fvpercent sex) nototals append
collect style header result, level(hide)
collect style row stack, nobinder spacer
collect style cell border_block, border(right, pattern(nil))
collect layout (sex[1]) (shortsite#result)
collect style cell result[fvpercent], sformat("%s%%")
Kind regards,

Ryan