Announcement

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

  • Calculating the difference between maximum and minimum variable value over three overlapping years

    Dear sata experts,

    I have a panel data set ranging from 2010-2018 for all firms listed i the US market.

    I am trying to calculate the difference between maximum and minimum ROA over three overlapping years, and not sure what is the right command to do this. Would appreciate any advice!

    Thanks
    Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	94.9 KB
ID:	1558889

    Last edited by Hamza Almustafa; 15 Jun 2020, 02:40.

  • #2
    Having posted over 50 times, you should understand the FAQ on asking questions. Please read them. Note that posting pictures is strongly discouraged – not only can we not work with those numbers, we have trouble reading them. I can't even tell if your data are annual or not. These guidelines are to make it easier for us to help you.

    I suspect what you want to do is after you have appropriately xtset your data, create a lead and lag value for ROA, and then use egen with rowmax to get the maximum ROA and egen with rowmin to get the min over the 3 year period.

    If you had provided the appropriate data using dataex, then I might've programmed this for you.

    If this is not annual data, then you should look at either statsby or user written rangestat.

    Comment


    • #3
      Hi Phil, thanks for your replies and efforts understanding what i need. I will read the FAQ next time posting question carefully.

      My data is annual unbalanced panel looks like the below table:
      firmid date ROA
      10043 17 0.23
      10043 18 0.36
      13944 17 0.15
      27394 16 0.18

      I need to generate a variable that consider the difference between the max and min of ROA over three overlapping years.

      Thanks once again and sorry for any inconvenience.

      Hamza

      Comment


      • #4
        Here is the dataex

        Code:
         No DataYear FirmROA
         1 2009     .177458693689945
         1 2010   .13660100950229914
         1 2011   .07814237265408061
         1 2012   .14186042905944918
         1 2013    .1742773063998069
         1 2014   .18942419471767397
         1 2015   .19638056464565778
         1 2016   .20806923166881067
         2 2009    .0879844632037548
         2 2010   .10316953256154864
         2 2011   .10796185957807884
         2 2012    .0840237599521784
         2 2013   .07039962449508282
         2 2014   .06201994434312046
         2 2015   .05819585927458937
         2 2016   .05527602836934021
         3 2009   .07760285074128807
         3 2010   .07721767767980453
         3 2011   .07199344464242503
         3 2012   .13609531975634778
         3 2013   .06537288119970874
         3 2014   .10157806321172656
         3 2015   .11655243569901982

        Comment

        Working...
        X