Announcement

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

  • Problem with moving average by a string variable.

    Hello. I have data from 1999q1 to 2019q2 for 6 different regions (string variable). Each observation is a share (between 0, 1). I would like to generate an other variable with the moving averages of the sare for each region using the two previous observations, the current observation and the next two.

    This is an example of my data:
    region date share
    europe 1999q1 0.243124324
    us 1999q1 0.3565476546
    asia 1999q1 0.9435435
    australia 1999q1 0.234234324
    africa 1999q1 0.567567657
    Thank you for helping!!!!!

  • #2
    If you

    Code:
    encode region, gen(Region) 
    tsset Region qdate
    then the smoothing resources of Stata are open to you. That's presuming that date is a numeric date variable.

    Please use dataex to show data examples. That is more informative. FAQ Advice #12 explains.

    Comment

    Working...
    X