Announcement

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

  • An Alternative to Xtile

    I have a data set with observations of 3.4 million. I am trying xtile funciton of egenmore, but is too slow
    Code:
    egen  PF=xtile(Ri_Rm) , by( date_ser) nq(10)
    where date_ser is time variable and Ri_Rm are stock returns, for which I want to create 10 quartiles on each specific date. As an laternative, I was trying to do the same with
    Code:
    bys date_ser Ri_Rm :  gen PF= int(10*(_n - 1) / _N) + 1
    However, it does not assign _n the way i wanted, i.e. to first sort with day_ser and withing that sorting assign _n based on Ri_Rm. Your help and comments will be appreciated.
    Regards
    --------------------------------------------------
    Attaullah Shah, PhD.
    Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
    FinTechProfessor.com
    https://asdocx.com
    Check out my asdoc program, which sends outputs to MS Word.
    For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.
Working...
X