Announcement

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

  • pshare with by

    Hello Stata experts!

    Looking for some advice on calculating percentiles of wages for a large dataset. Its a panel data in the following form:

    year FirmId Emp_Wage
    1 11 1
    1 11 2
    1 11 3
    1 12 11
    1 12 12
    1 12 13

    This repeats for about 10 years. I would like to have the percentile distribution of wages for each of the firms (within firm) for each of the year.
    The year part can be handled using the if clause since there are few (10) years.

    But there are more than 1000 firms. For each firm, I would like to have the distribution of wages in percentiles.
    I try to use the pshare command, but it cannot be combined with "by".

    Can anyone help me by suggesting an alternate or maybe provide link to a thread if this has been discussed before?

    Thanks a ton!
    Last edited by Jason Cruso; 30 Sep 2017, 00:48.

  • #2
    I am not familiar with the pshare program. Please read the FAQ where, among other things, you are asked to explain where programs that are not part of official Stata come from.

    That said, there are basically two approaches you can take to this.

    Code:
    levelsof FirmId, local(firms)
    levelsof year, local(years)
    foreach f of local firms {
        foreach y of local years {
            // pshare ... if year == `y' & FirmID == `f'  COMMAND GOES HERE
            // OTHER COMMANDS TO PUT
            // THE pshare RESULTS INTO THE DATA SET
        }
    }
    The other generic approach is, if -pshare- returns the results you are interested in in r() or e(), then you can use -statsby-, which will automate all of the details of the other approach for you.

    Finally, I should mention that if -pshare- allows -by:- prefixing and puts its results into the current data set in memory, then you can just do

    Code:
    by FirmId year, sort: pshare...

    Comment


    • #3
      Thanks Clyde for the reply. I will try the code as suggested by you.
      I use Stata 15.0 and i guess pshare is a part of stata 15?

      Comment


      • #4
        Not exactly (you have to install -pshare- manually). Please "ssc install pshare".

        Ho-Chuan (River) Huang
        Stata 19.0, MP(4)

        Comment


        • #5
          Ok. Thanks. Maybe it was my admin who did it for me before I knew it. Anyway, I got the information about pshare from one of the pdf documentation made by Ben Jann, University of Bern.

          Comment

          Working...
          X