Announcement

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

  • Calculate the asset growth rate for quarterly panel data

    Dear Statalists,

    My main target here is to calculate the asset growth rate over the last quarter for a specific firm, the data is quarterly panel, for example:
    firm_id year quarter assets
    37 1997 1 58891
    37 1997 2 57317
    37 1997 3 57993
    37 1997 4 60834
    37 1998 1 61299
    37 1998 2 61260
    37 1998 3 60447
    37 1998 4 61351
    37 1999 1 61655
    37 1999 2 62144
    37 1999 3 63308
    37 1999 4 63963
    242 1997 1 19925
    242 1997 2 20764
    242 1997 3 19845
    242 1997 4 20676
    242 1998 1 20663
    242 1998 2 20898
    242 1998 3 20761
    242 1998 4 21914
    242 1999 1 21404
    242 1999 2 21404
    242 1999 3 21824
    242 1999 4 22885
    279 1997 1 89224
    279 1997 2 88541
    279 1997 3 89206
    279 1997 4 87353
    279 1998 1 86906
    279 1998 2 86241
    279 1998 3 88516
    279 1998 4 90896
    279 1999 1 90206
    279 1999 2 92940
    279 1999 3 92302
    279 1999 4 93211

    firm_id represents a unique firm identifier, so, is "egen" function appropriate here?

    All I need is to generate another variable named as assets_growth_rate=(Assets in Quarter_n+1-Assets in Quarter_n)/Assets in Quarter_n.

    Many thanks for your help in advance.

    With kind regards,

    Cong
    Last edited by Cong Gu; 30 Nov 2015, 20:52.

  • #2
    Probably the simplest way to do this is:

    Code:
    gen quarterly_date = quarterly(string(year)+"q"+string(quarter), "YQ")
    xtset firm_id quarterly_date
    gen assets_growth_rate = (F.assets-assets)/assets
    Not only is the code compact, but it will automatically generate missing values where there are gaps in the series of quarters.

    Comment


    • #3
      Many thanks!!really appreciate your help!!

      Comment


      • #4
        Note also the yq() function.

        Comment

        Working...
        X