Announcement

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

  • xtile quantile limits

    Dear all,

    When using
    Code:
    xtile CAT_VAR = CONT_VAR, nq(5)
    I get a nice new categorical variable with numbers in 1,..., 5 according to their quintile in the continuous variable. I am, however, also interested in seeing the quintile limits that must have been used by xtile to slot each observation into its according bin.
    Can anyone help me in how to print those limits?

    Thank you for your support,
    best wishes,
    Hagen

  • #2
    Some technique:

    Code:
    . sysuse auto, clear
    (1978 Automobile Data)
    
    . xtile bin5=mpg, nq(5)
    
    . _pctile mpg, nq(5)
    
    . ret li
    
    scalars:
                     r(r1) =  17
                     r(r2) =  19
                     r(r3) =  22
                     r(r4) =  25
    
    . tabstat mpg, by(bin5) s(n min max)
    
    Summary for variables: mpg
         by categories of: bin5 (5 quantiles of mpg)
    
        bin5 |         N       min       max
    ---------+------------------------------
           1 |        18        12        17
           2 |        17        18        19
           3 |        13        20        22
           4 |        12        23        25
           5 |        14        26        41
    ---------+------------------------------
       Total |        74        12        41
    ----------------------------------------

    Comment


    • #3
      ah, great, thanks! I should have figured that out by myself

      Comment

      Working...
      X