Announcement

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

  • Combine Year + Quarter Data

    Hi all,

    I'm sure there is a very simple solution. I have two variables 'Year' (2000 to 2016) and 'Quarter' (1 to 4). I'm trying to generate a very simple combination i.e. 2000q1, 2000q2....2016q3, 2016q4.

    I've tried the expected = yq(year, quarter) but no luck.

    Any advice would be much appreciated.

  • #2
    That works for me:


    Code:
    . clear
    
    . set obs 1
    obs was 0, now 1
    
    . gen y = 2016
    
    . gen  q = 3
    
    . gen yq = yq(y, q)
    
    . l
    
         +----------------+
         |    y   q    yq |
         |----------------|
      1. | 2016   3   226 |
         +----------------+
    
    . format yq %tq
    
    . l
    
         +-------------------+
         |    y   q       yq |
         |-------------------|
      1. | 2016   3   2016q3 |
         +-------------------+
    If your error is not now clear, please give us more information on exactly what you did (or didn't) do.

    Comment


    • #3
      Worked perfectly. Thanks for your help, much appreciated.

      Comment


      • #4
        I think that the following code will do (suppose that your data set spans the 2000q1-2016q4 period):
        Code:
        gen t=q(2000q1)+_n-1
        format t %tq
        Ho-Chuan (River) Huang
        Stata 17.0, MP(4)

        Comment


        • #5
          Hi all,

          I have a similar question.

          I have to analyze quarterly data, but I have only variables 'year' and 'month' in my data.

          So I need to combine these 2 variables (year) and (month) into a new variable (quarter):
          E.g. 2005 and 7 (july) should become 2005q3.


          Which commands do I need to use in Stata to become this quarterly data?

          Thanks!

          Comment


          • #6
            #5 is a duplicate post. Answered elsewhere.

            Comment


            • #7
              (continuation of my previous #6)

              -- that is in the thread https://www.statalist.org/forums/for...terly-variable

              Comment

              Working...
              X