Announcement

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

  • Issues with switching date as a string variable in order to convert my data into a time series data

    Code:
    gen time=date(date, "qy")
    variable name: date
    storage type: str7
    display format: %9s

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str7 date
    "Q1 1980"
    "Q2 1980"
    "Q3 1980"
    "Q4 1980"
    "Q1 1981"
    "Q2 1981"
    "Q3 1981"
    "Q4 1981"
    "Q1 1982"
    "Q2 1982"
    "Q3 1982"
    "Q4 1982"
    "Q1 1983"
    "Q2 1983"
    "Q3 1983"
    "Q4 1983"
    "Q1 1984"
    "Q2 1984"
    "Q3 1984"
    "Q4 1984"
    "Q1 1985"
    "Q2 1985"
    "Q3 1985"
    "Q4 1985"
    "Q1 1986"
    "Q2 1986"
    "Q3 1986"
    "Q4 1986"
    "Q1 1987"
    "Q2 1987"
    "Q3 1987"
    "Q4 1987"
    "Q1 1988"
    "Q2 1988"
    "Q3 1988"
    "Q4 1988"
    "Q1 1989"
    "Q2 1989"
    "Q3 1989"
    "Q4 1989"
    "Q1 1990"
    "Q2 1990"
    "Q3 1990"
    "Q4 1990"
    "Q1 1991"
    "Q2 1991"
    "Q3 1991"
    "Q4 1991"
    "Q1 1992"
    "Q2 1992"
    "Q3 1992"
    "Q4 1992"
    "Q1 1993"
    "Q2 1993"
    "Q3 1993"
    "Q4 1993"
    "Q1 1994"
    "Q2 1994"
    "Q3 1994"
    "Q4 1994"
    "Q1 1995"
    "Q2 1995"
    "Q3 1995"
    "Q4 1995"
    "Q1 1996"
    "Q2 1996"
    "Q3 1996"
    "Q4 1996"
    "Q1 1997"
    "Q2 1997"
    "Q3 1997"
    "Q4 1997"
    "Q1 1998"
    "Q2 1998"
    "Q3 1998"
    "Q4 1998"
    "Q1 1999"
    "Q2 1999"
    "Q3 1999"
    "Q4 1999"
    "Q1 2000"
    "Q2 2000"
    "Q3 2000"
    "Q4 2000"
    "Q1 2001"
    "Q2 2001"
    "Q3 2001"
    "Q4 2001"
    "Q1 2002"
    "Q2 2002"
    "Q3 2002"
    "Q4 2002"
    "Q1 2003"
    "Q2 2003"
    "Q3 2003"
    "Q4 2003"
    "Q1 2004"
    "Q2 2004"
    "Q3 2004"
    "Q4 2004"
    end


    Hi, I'm having a lot of issues trying to convert my data into a time series data set as quarterly data. For some reason, I'm unable to do so. Please could anyone help me out with this? Thank you.
    Last edited by Shazzle Singh; 11 Jan 2019, 07:31.

  • #2
    Try
    Code:
    gen quarter = quarterly(substr(date, -4, 4) + "" + substr(date, 1,2), "YQ")
    format quarter %tq!Qq-YY

    Comment


    • #3
      Thank you for your prompt reply. It worked!

      Comment


      • #4
        Please contact the administrators with a full real name, such as we request in the FAQ Advice.

        Comment

        Working...
        X