Announcement

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

  • How to create a table for all dates using start date and end date

    I need help to create a "new table" with variable "edate" showing all dates from 1July1997 to 30Dec2023.

  • #2
    A quick calculation shows the number of distinct dates to be

    Code:
    . di mdy(12,30,2023) - mdy(7,1,1997) + 1
    9679
    That many columns in a table would be impractical so far as I can see, and I can't see that that many rows, although more manageable, is even close to practical.

    Code:
    help limits
    in your Stata shows some limits for particular commands.


    Comment


    • #3
      Thanks Nick, I need the "date" variable in one column that has "start date" and "end date" in continuity with no missing date in between the dates. I need to merge this dataset with to other dataset that contains non-continuous "date_id".

      Comment


      • #4
        So, you don't mean table when you say table: you mean a variable. What you can do is something like


        Code:
        clear
        set obs 9679
        gen daily_date = mdy(6,30,1979) + _n
        format daily_date %td
        and a test is

        Code:
        list if inlist(_n, 1, _N)

        Comment


        • #5
          Thank you Nick, it worked.

          Comment

          Working...
          X