Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Formatting using dtable

    Hello,
    I am having some issues with my code for dtable. Been trying to insert parenthesis for interquartile range and a "-" betewen q1 and q3 eg. (q1-q3) but it does not seem to work.
    Tried looking at the stata manual as well as this forum but have not come across a potential solution.
    Here is my code:


    dtable, by(pregcat, notests totals nomissing) define(meansd=mean sd, delimiter({&plusmn})) define(iqi= q1 q3, delimiter("-"))continuous(age_preg bmi , statistics(mean sd)) continuous(gravida para creat_prepreg egfr_prepreg , statistics(median q1 q3)) factor(site race renaldx cvs diabetes transplant smoke sle prepreg_antihypertensives immunosupp, statistics(fvfrequency fvpercent)) nformat(%9.2g mean sd frequency median q1 q3 fvfrequency fvpercent) title(Table 1. Demographic characteristics of participants) nformat(%6.0f p25 p75 median) sformat("(%s)" iqi) nformat(%6.1f mean sd) sformat("%s" meansd) column(by(hide) total(All))



    Thank you very much

    Jennifer

  • #2
    What you are missing is the use of your composite result iqi in the statistics() option. Where you have
    Code:
    statistic(median q1 q3)
    you want
    Code:
    statistic(median iqi)
    Here is a working example using the auto data.
    Code:
    sysuse auto
    
    dtable, define(iqi = q1 q3, delimiter(" - ")) ///
        sformat("(%s)" iqi) ///
        nformat(%9.2g mean sd median q1 q3) ///
        continuous(price weight length, statistics(median iqi)) /// <- iqi
        continuous(mpg turn trunk, statistics(mean sd))
    Here is the resulting table.
    Code:
    ----------------------------------------
                                Summary     
    ----------------------------------------
    N                                     74
    Price                 5007 (4195 - 6342)
    Weight (lbs.)         3190 (2240 - 3600)
    Length (in.)             193 (170 - 204)
    Mileage (mpg)                   21 (5.8)
    Turn circle (ft.)               40 (4.4)
    Trunk space (cu. ft.)           14 (4.3)
    ----------------------------------------

    Comment


    • #3
      Thank you very much Jeff - yes that solved my problem!

      Comment

      Working...
      X