Announcement

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

  • xtile

    i am trying to see the distribution in my data.. i used the command xtile command and generated my quintile n(5).. what command should i run if i want to see the distribution of the variable x in different sectors or regions..
    xtile variable x5=variable x,nq(5)
    then i ran a tabstat variable x5 ; or tab variable x5..
    will it be fine if i run
    tab sector variable x5
    tab sector variable x5 if region=1

  • #2
    Olive:
    do you mean something along the following lines?
    Code:
    . use "C:\Program Files (x86)\Stata15\auto.dta"
    (1978 Automobile Data)
    
    . xtile price_nq = price , nq(4)
    
    . bysort foreign: tab price_nq
    
    --------------------------------------------------------------------------------------------------------
    -> foreign = Domestic
    
    4 quantiles |
      of price  |      Freq.     Percent        Cum.
    ------------+-----------------------------------
              1 |         15       28.85       28.85
              2 |         14       26.92       55.77
              3 |         12       23.08       78.85
              4 |         11       21.15      100.00
    ------------+-----------------------------------
          Total |         52      100.00
    
    --------------------------------------------------------------------------------------------------------
    -> foreign = Foreign
    
    4 quantiles |
      of price  |      Freq.     Percent        Cum.
    ------------+-----------------------------------
              1 |          4       18.18       18.18
              2 |          4       18.18       36.36
              3 |          7       31.82       68.18
              4 |          7       31.82      100.00
    ------------+-----------------------------------
          Total |         22      100.00
    
    
    .
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Carlo Lazzaro gives good advice as usual: with his example


      Code:
      tab price_nq foreign
      would also work well.


      Otherwise #1 cannot be the syntax you ran, as it is sprinkled with syntax errors. To get better replies, and use your own time to better effect, please show us a data example and the exact code you tried. https://www.statalist.org/forums/help#stata applies as always.
      Last edited by Nick Cox; 21 Oct 2019, 07:39.

      Comment


      • #4
        thank you for your earlier explanations..
        if i use
        egen rmpce5 = xtile(rmpce), nq(5)
        why do i get

        unknown egen function xtile()

        what is the error here then

        Comment


        • #5
          sorry i got the answer..
          this STATA version required egenmore to be installed

          Comment

          Working...
          X