Announcement

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

  • convert number to date

    I have data that is monthly but not labeled. For example:

    Code:
    clear
    input firm_id time value
    1 1 3
    1 2 4
    1 3 7
    1 4 9
    1 5 13
    1 6 15
    end
    I also know that time=1 is Jan 1999. Using ym date format, Jan 1999 is month 468 (see code below).

    Code:
    display ym(1999, 1)
    My small problem is the following code throws an error [r(198) invalid syntax].

    Code:
    gen month_i=ym(time+467)
    Any idea on how to fix this?

    Thanks in advance.


  • #2
    how about
    Code:
    gen month_i = time+467
    format month_i  %tm

    Comment


    • #3
      The syntax error is that ym() requires two arguments, not one.

      Another solution would be ym(1998, 12) + time

      Comment


      • #4
        Rich Goldstein : Thank you.

        Comment


        • #5
          Nick Cox : Thanks Nick

          Comment

          Working...
          X