Announcement

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

  • Beginner: Date-Format: 01MMYYYY. How to tell STATA that I have Monthly not daily data

    Hello, sorry for my bad English. I have a maybe trivial question: I downloaded Data from the FED (monthly) on FX-$/€ and it comes in the following format: 01jan1999, 01feb1999, .... 01march2016 as an Excel-File. Now if I try to tell STATA (under "declare Dataset to be time-series data) that this are monthly observations it gives me:

    Variable DATE had been formatted %td (a daily period),
    and you asked for a monthly period. Are you sure that is
    what you want? It has been done; DATE is now formatted %tm.


    And than looks like this:

    DATE
    3147m2
    3149m9
    3152m1
    3154m8
    3157m2
    3159m9
    3162m3
    3164m10


    How can I tell STATA that this are already monthly observations that just always have 01 for the 1st of the month attached?

    Thank you for your help

    Karl


  • #2
    Changing a display format will not convert a date from one basis to another.
    http://www.stata-journal.com/sjpdf.h...iclenum=dm0067

    What you want to know is all documented at

    Code:
    help dates
    One way to do it is to import as daily dates and then convert to monthly.

    Code:
    clear
    input str11 ddate
    "01jan1999"
    "01feb1999"
    "01march2016"
    end
    gen mdate = mofd(daily(ddate, "DMY"))
    format mdate %tm
    list
    
    +----------------------+
    | ddate mdate |
    |----------------------|
    1. | 01jan1999 1999m1 |
    2. | 01feb1999 1999m2 |
    3. | 01march2016 2016m3 |
    +----------------------+
    As your variable is already numeric, what is relevant to you is pushing the values through mofd(). after which formatting as a monthly date will make sense.
    Last edited by Nick Cox; 02 May 2016, 06:34.

    Comment


    • #3
      Thank you very much. So I did the following:

      generate DATEm = mofd(DATE) and THEN changed the format and now I have a Variable DATEm which is 1999m1, 1999m2, ... 2016m2, 2016m3.
      Last edited by Karl Kraus; 02 May 2016, 07:03.

      Comment


      • #4
        Sounds right. But it is (its values are) 468 to 674. It displays as 1991m1 to 2016m3 with display format %tm

        Comment


        • #5
          Sir, I want to change the format 1999m1 to 01jan1999? Please help

          Comment


          • #6
            The form of address "Sir" is not needed here and indeed inappropriate.

            See #4 https://www.statalist.org/forums/for...-to-stata-date and ask your question again in that thread if you don't work out an answer.

            Comment

            Working...
            X