Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re:


From   "Leny Mathew" <lenymathewc@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Re:
Date   Fri, 1 Feb 2008 10:07:28 -0500

Hi Shannon,
                 stata stores dates as a number which represents the
number of days from 1/1/1960. You can get the corresponding value for
your date by typing
display date("date", "DMY")

For example, if the date is  5 sept 2007, you would have to type:
display date("9/5/2007", "MDY")
Depending on the way the date is written, you can use "DMY" or "MDY".
Once you get that number, then you can use the 'generate' command to
create the variable you want. So, assuming that your date is 5 sept,
2007, stata would give you the following:

 display date("9/5/2007", "MDY")
17414

Then, to create your new variable,

gen var= 1 if  date >17414 & date != .
replace var=0 if date <=17414


Hope this helps,

Leny
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index