Announcement

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

  • Quintiles using xtile

    Hello,

    I want to divide the consumer expenditure variable into quintiles. I have individual-level data, but the expenditure is given at the household level. I'm using the below codes to generate the required variable:

    Code:
    sort common_id
    Code:
    egen byte tag = tag(common_id)
    Code:
    by common_id: egen MCE = xtile(usual_monthly_con_exp) if tag & sector==1, nq(5)
    I'm not sure about it because stata is taking too long. Please help.
    Last edited by Varsha Vaishnav; 18 Mar 2024, 13:28.

  • #2
    If sector can vary within household then there could be observations for which sector == 1 but tag == 0.

    I can't judge that without seeing a real(istic) data example but -- setting sector aside -- it seems more likely that you want just

    Code:
    egen byte tag = tag(common_id)  
    egen MCE = xtile(usual_monthly_con_exp) if tag, nq(5)  
    
    bysort common_id (tag) : replace MCE = MCE[_N]
    as it does not seem plausible that you are assigning to quantile bins separately within households and that makes no sense anyway if expenditure is reported as the same constant for each household.

    Last edited by Nick Cox; 18 Mar 2024, 14:48.

    Comment


    • #3
      Thank you, Nick. I now know where I was going wrong.

      Comment

      Working...
      X