Tuesday, June 19, 2012

dates and times

useful commands:

1. help dates_and_times

Fro example: You have a date stored in "date", an example being "22/7/2010".  In this case, you want to create an SIF(format stata understands) date instead of a datetime.  You type

               . gen eventdate = date(mystr, "DMY")

and     then type  so that stata displays the dates in a human readable format.

   format eventdate %td

1 comment:

  1. and when u want to recall soem data based on dates do the following:

    gen before = cond(hiredon < td(15jun2004), 1, 0) if !missing(hiredon)

    You can type SIF date values by typing the date inside td(), as in td(15jun2004).

    ReplyDelete