Announcement

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

  • Convert monthly data to quarterly format

    I would like to convert my data from monthly to quarterly format in STATA. This will be the sum of the two variables, outpatient and admissions, into quarterly format. My data is in the attached format:

    How do I go about it?
    Monthly hospital data

  • #2
    Please note advice against photos in the FAQ and for giving us sample data in CODE listings.

    You have year and month variables.

    You can get quarterly dates from monthly dates by

    Code:
    gen qdate = qofd(dofm(ym(year, month)))
    format %tq date
    Then

    Code:
     
    collapse (sum) outpatient (sum) admissions, by(hospital qdate) 
    ​

    Comment


    • #3
      Thank you very much, this is very usefull for myself

      Comment


      • #4
        #2 One small typo there:
        format %tq qdate

        Comment


        • #5

          Eddie Brighton Correct and thanks!

          Comment

          Working...
          X