Announcement

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

  • converting string form quarterly data into a form for tsset

    My data looks like this:

    I want it to look like

    1987q1
    1987q2
    1987q3
    1987q4
    1988q1
    1988q2
    1988q3
    1988q4 etc

    where qtr has format %tq.
    I tried

    replace qtr=subinstr(qtr,"Jan to Mar","",.)+"q1" but this only works the first time round. Please advise.

    Robert


  • #2
    Copy and paste the output of

    Code:
    dataex qtr in 1/20
    At the moment, we have no clue about the contents of this variable.

    Comment


    • #3
      I agree with Andrew Musau, except that there is a fragment of a detail there which allows some wild guesses. You may be able to adapt this.

      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input str16 problem
      "Jan to Mar 2024"
      "Apr to Jun 2024"
      "Jul to Sep 2024"
      "Oct to Dec 2024"
      end
      
      gen wanted = qofd(dofm(monthly(word(problem, 1) + word(problem, -1), "MY")))
      
      list 
      
           +--------------------------+
           |         problem   wanted |
           |--------------------------|
        1. | Jan to Mar 2024      256 |
        2. | Apr to Jun 2024      257 |
        3. | Jul to Sep 2024      258 |
        4. | Oct to Dec 2024      259 |
           +--------------------------+
      
      . format wanted %tq
      
      . l
      
           +--------------------------+
           |         problem   wanted |
           |--------------------------|
        1. | Jan to Mar 2024   2024q1 |
        2. | Apr to Jun 2024   2024q2 |
        3. | Jul to Sep 2024   2024q3 |
        4. | Oct to Dec 2024   2024q4 |
           +--------------------------+

      Comment


      • #4
        Thanks, guys. Some of my original post seems to have disappeared. This is what the data looks like.

        And I want to convert this into standard time series quarterly format. i.e. 1987q1,1987q2,1987q3,1987q4, etc

        Comment


        • #5
          Originally posted by Robert Cressy View Post
          Some of my original post seems to have disappeared. This is what the data looks like.
          Still, we cannot see the data. The recommended way to present data in the forum is to use the dataex command (see post #2).

          Comment


          • #6
            ghost data. Please click "Preview" before posting reply. And please don't just run away after posting. Time Is Valuable.

            Comment

            Working...
            X