Announcement

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

  • How to calculate the monthly average from daily data?

    I have daily data from 03-01-1994 to 29-12-1995. The first column is date and the second column is my observation. I want to estimate the monthly average for each month, then, i want to export the results into excel. So please suggest me the Stata code. I have attached the data file here.
    Attached Files

  • #2
    You can try:

    Code:
    gen Month_Year = substr(date, 4, .)
    drop if Month_Year == ""
    
    bysort Month_Year: egen Monthly_Avg = mean(y)
    This would give identical observations for Monthly_Avg for each day of the same month, but each observation should be the montly average of y.

    Comment


    • #3
      Dear Nate Tillern, Thank you

      Comment

      Working...
      X