Announcement

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

  • Problems with Dummy creation from percentiles

    Hello, I have a variable called "GapfromMedian" (which represents the gap of Leverage that an industry has from the median of the industry)

    and a dummy variable named "industry" (which represents the industry in which the firm evolves). From these variables I would like to create a dummy (awayfrom) which takes value :

    1, if "GapfromMedian" is <p25 or =>p75

    0, if "GapfromMedian" is >=p25 and <p75

    To sum up, I have 48 industries, so 48 industries median. Every firm in an industry which is <p25 or =>p75 will have to take value 1 in the new "awayfrom" variable.

    If that can help you feel free to look at the attachments.
    Attached Files

  • #2
    This might work.

    I assume you have the GapfromMedian generated. You can use egen to get the p25 and p75.

    Code:
    bys industry: egen p25 = pctile(GapfromMedian), p(25)
    bys industry: egen p75 = pctile(GapfromMedian), p(75)
    g awayfrombig = GapfromMedian<p25 | GapfromMedian>p75
    Last edited by George Ford; 14 Dec 2022, 09:05.

    Comment


    • #3
      Thanks a lot ! It works amazingly

      Comment

      Working...
      X