Announcement

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

  • Summary statistics excluding observations already used

    Hi there,

    I'm writing a research project about how profitability responds to a CEO pay cut. I therefore look at observations that have a pay cut (more than 25% decrease in pay cuy YoY) and take the 5 years before and 5 years after. I want to compare the mean of these observations with the observations without a pay cut. To calculate the observations with a pay cut, I use the following code:
    Code:
    bys globalcompanykey (datayearfiscal): gen PM_level_min5 = profitmargin[_n-5] if tdc2percentchangeyeartoyear[_n] < -25  & _n != 1 & profitmargin !=.
    To calculate the normal observations, I use the following code:
    Code:
    bys globalcompanykey (datayearfiscal): gen PM_level_normal_min5 = profitmargin[_n-5] if tdc2percentchangeyeartoyear[_n] > -25 & _n != 1 & profitmargin !=.
    I do this for _n - 5 until _n + 5. However, with the code above, I also take for the normal observations the observations until the pay cut and after pay cut. I would like to exclude the 5 years before a pay cut and 5 years after a pay cut from the second code. How can I do this?

    Thanks.

  • #2
    I think you will have a much better chance of getting a helpful response if you fire up the -dataex- command and show example data. If you are running version 17, 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    In addition, the question as posed fails to explain complicated situations. Suppose in some company there is a ceo pay cut in 2005 and again in 2008. Then year 2001 is within five years of the first pay cut but not the second. Similarly, 2012 is within five years of the second but not the first. So how are years like this to be handled?

    When asking for help with code, always show example data. When showing example data, always use -dataex-.

    Comment

    Working...
    X