Announcement

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

  • How to convert quarterly string date to Stata date

    I have dates in the following format, want to convert it to Stata dates, is there any function for this type of dates
    Code:
    clear
    input str7 q
    "1955 Q2" 
    "1955 Q3" 
    "1955 Q4" 
    "1956 Q1" 
    "1956 Q2" 
    "1956 Q3" 
    "1956 Q4" 
    "1957 Q1" 
    "1957 Q2" 
    "1957 Q3" 
    end
    Regards
    --------------------------------------------------
    Attaullah Shah, PhD.
    Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
    FinTechProfessor.com
    https://asdocx.com
    Check out my asdoc program, which sends outputs to MS Word.
    For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

  • #2
    Thanks for the clear example. quarterly() will work fine here. Documented under help datetime.

    Code:
    . clear
    
    . input str7 q
    
                 q
      1. "1955 Q2"
      2. "1955 Q3"
      3. "1955 Q4"
      4. "1956 Q1"
      5. "1956 Q2"
      6. "1956 Q3"
      7. "1956 Q4"
      8. "1957 Q1"
      9. "1957 Q2"
     10. "1957 Q3"
     11. end
    
    .
    . gen qdate = quarterly(q, "YQ")
    
    . format qdate %tq
    
    . list
    
         +------------------+
         |       q    qdate |
         |------------------|
      1. | 1955 Q2   1955q2 |
      2. | 1955 Q3   1955q3 |
      3. | 1955 Q4   1955q4 |
      4. | 1956 Q1   1956q1 |
      5. | 1956 Q2   1956q2 |
         |------------------|
      6. | 1956 Q3   1956q3 |
      7. | 1956 Q4   1956q4 |
      8. | 1957 Q1   1957q1 |
      9. | 1957 Q2   1957q2 |
     10. | 1957 Q3   1957q3 |
         +------------------+

    Comment


    • #3
      Thanks for your reply and solution. The clear example is a product of yours and Robert dataex program.
      Regards
      --------------------------------------------------
      Attaullah Shah, PhD.
      Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
      FinTechProfessor.com
      https://asdocx.com
      Check out my asdoc program, which sends outputs to MS Word.
      For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

      Comment


      • #4
        It did seem that way....

        Comment


        • #5
          I have a related question. I am using quarterly data for synthetic control and am unable to display the quarters in the graph I am generating HRFs. It is instead displaying in SIF. My current code for the graphs is the following:

          synth ratio_prev $covars, trunit(34) trperiod(233) xperiod(203(1)232) nested allopt fig

          Any help is appreciated.

          Comment

          Working...
          X