Announcement

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

  • Multiple If Statements using tabstat

    Hello,

    Is it possible to impose different if statement restrictions depending on the statistic in the same tabstat table?

    tabstat ***MY SET OF VARIABLES*** if status==0 , stat(mean count min max)

    This works fine, but I would like the count to include the whole sample, without the restriction. Any suggestions?

    If this works, I would also like to add counts of specific missing responses (i.e. for each variable, how many .a are there?)

    Thank you!

  • #2
    You could generate the count variables and display them on the column. With non-overlapping missing values, this may not make a lot of sense since each variable will have its own sample.

    Code:
    sysuse auto, clear
    gen count=_N
    tabstat price mpg weight count if !foreign , stat(mean min max)
    But you could also have done

    Code:
    egen count= total(!missing(price) & !missing(mpg) & !missing(weight))
    Res.:

    Code:
    . tabstat price mpg weight count if !foreign , stat(mean min max)
    
       stats |     price       mpg    weight     count
    ---------+----------------------------------------
        mean |  6072.423  19.82692  3317.115        74
         min |      3291        12      1800        74
         max |     15906        34      4840        74
    --------------------------------------------------

    Comment

    Working...
    X