Announcement

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

  • Editing a quarterly time variable in order to apply the "tsset" command

    Hi Stata people;

    I'm working with Stata 13.1 version, and I have this data at hand:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str10 Trimester float Regulated_Savings
    "31/03/2012" 602.745
    "30/06/2012" 610.186
    "30/09/2012" 618.868
    "31/12/2012" 649.851
    "31/03/2013" 663.513
    "30/06/2013" 671.947
    "30/09/2013" 676.439
    "31/12/2013" 675.125
    "31/03/2014" 680.735
    "30/06/2014" 684.159
    "30/09/2014" 685.923
    "31/12/2014" 685.712
    "31/03/2015" 691.676
    "30/06/2015" 695.007
    "30/09/2015" 696.561
    "31/12/2015" 698.123
    "31/03/2016" 703.648
    "30/06/2016" 707.075
    "30/09/2016" 710.701
    "31/12/2016" 714.973
    "31/03/2017" 719.871
    "30/06/2017"  725.44
    "30/09/2017" 729.505
    "31/12/2017" 733.054
    "31/03/2018"  739.07
    "30/06/2018" 742.654
    "30/09/2018" 745.892
    "31/12/2018" 751.387
    "31/03/2019" 758.858
    "30/06/2019"  763.99
    "30/09/2019" 767.992
    "31/12/2019" 771.523
    "31/03/2020" 781.125
    "30/06/2020"  799.21
    "30/09/2020" 806.111
    "31/12/2020" 813.715
    "31/03/2021" 825.781
    "30/06/2021" 832.057
    "30/09/2021"  834.94
    "31/12/2021"  833.74
    "31/03/2022" 845.136
    "30/06/2022" 848.772
    "30/09/2022"  862.34
    "31/12/2022" 874.131
    "31/03/2023" 902.552
    "30/06/2023" 914.995
    "30/09/2023" 926.074
    "31/12/2023" 935.543
    "31/03/2024"  942.37
    "30/06/2024" 946.971
    "30/09/2024" 953.214
    "31/12/2024" 955.681
    end
    As you can see, the data is about the savings of the French people (by Billions of Euros) defined by quarter (or Trimester), from 2012 to 2024. The goal is to transform the "Trimester" variable into a time variable to be able to apply the "tsset" command and draw a time graph for the monetary variable. I won't mind if that variable would be defined as "1st Quarter of 2012, 2nd Quarter of 2012, ..., Last (or 4th) Quarter of 2024" or any other form, I just want it to be a time variable suitable for that kind of study and graph.

    Any help please?

    With many thanks!

  • #2
    You don't need tsset to draw a graph here. You do need a numeric quarterly date variable.

    Code:
    gen QDate = qofd(daily(Trimester, "DMY"))
    
    format QDate %tq 
    
    line Regulated_Savings QDate
    See (as for many of the threads you start)

    Code:
    help datetime 
    for the basics as usual and Sections 2.4 and 2.6 of https://journals.sagepub.com/doi/pdf...6867X251341416
    for the two steps you need here.

    Comment


    • #3
      Nick Cox Thanks for the help! It worked.
      The thing is that when I see a time variable, I always think that I should defined it as such and apply the "tsset" command and then draw a time graph. You are right, in this case, it doesn't change anything if I don't defined that newely created variable as a time variable.

      Comment


      • #4
        What you need depends on the command. line manifestly is a general command for line graphs that isn't limited to time series.

        tsline is an example of a command that requires a tsset first.

        Code:
        tsset QDate
        would do no harm here; it's just not essential to get the graph.

        Comment


        • #5
          Nick Cox Thanks for the clarification.

          Comment

          Working...
          X