Announcement

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

  • Generating a growth rate

    Hi all,

    I am trying to generate the growth rate in a variable by a monthly date (modate or modate2, either works). I want to see the growth, for instance, between share_mandated_month in month 635 to month 636. I have tried bys modate2: g growthrate=(share_mandated_month[_n]-share_mandated_month[_n-1])/share
    > _mandated_month[_n-1] but it just gives me 0 for all values. I know that I have lots of observations of a month, but still want every observation to just show the growth rate between that month and the last for the growth rate variable.


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(modate modate2 share_mandated_month)
    635 56  .6012899
    635 56  .6012899
    635 56  .6012899
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    636 57 .54626864
    end
    format %tm modate

  • #2
    Code:
    frame put modate share_mandated_month, into(working)
    frame working {
        duplicates drop
        tsset modate
        gen wanted = D1.share_mandated_month/L1.share_mandated_month
    }
    frlink m:1 modate, frame(working)
    frget wanted, from(working)
    That said, why are you carrying so many duplicate observations in your data set?

    Comment


    • #3
      So, they aren't actually duplicate observations---the data is at the household id month level, so each month has a different household id. However, I want the growth rate by month only, not by household id. Does that make sense?

      Comment


      • #4
        Yes, makes perfect sense. Context is everything!

        Comment


        • #5
          Thank you so much for your help! It workeD!! Thank you for always replying and helping me.

          Comment

          Working...
          X