Announcement

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

  • How to subsample a panel data based on two condition?

    Hi all,
    I have panel data on firms in 3 countries (e.g., 100 firms in 3 countries in 5 years, and event happen at the 3rd year in all countries at the same time). For an example, for each firms I have 4 variables, including:

    y x1 x2 profitability

    (while y is dependent variable and the rest are independent variables). I am examining the impact of a law on y by using differences-in-differences. There is a theory that suggests that the law has more impact on firms' with high profitability. Therefore, I want to test the impact of laws on a sample of firms with high profitability. One possible solution is to separate the sample by the mean of profitability before event date.

    In general, each firms has 5 profitability (given my sample period is 5 (from 2016 to 2021)). However, there are some firms only have 4 or 3 observations due to missing values.

    I am wondering how to code to get the subsample that firms where the profitability in year 2017 higher than median or at the quantile top 10%.

    Thank you.

  • #2
    Code:
    summ profitability if year==2017 , d
    will get you the r(p50) and r(p90) values with which to great a variable.

    Comment


    • #3
      Originally posted by George Ford View Post
      Code:
      summ profitability if year==2017 , d
      will get you the r(p50) and r(p90) values with which to great a variable.
      George Ford , yes, I understand the code, but what I am thinking and looking for is how to code to keep or assign a firms that has the profitability of year 2017 > r(p50)

      I was writting this code and it is pretty fail

      Code:
       su lprofits_w1 if year1==2017
            bysort TYPE2: gen pro_1_year = 1 if (year1=2017 & r(mean))

      Comment


      • #4
        I found the results now, thank you

        Comment

        Working...
        X