|
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: minor annoyance
If you are doing this, even better would be to include the following in
profile.do
global today date("\`c(current_date)'","DMY")
Note the backslash before the open-single-quote (`), which means the
global macro contains the literal string `c(current_date)' which is
evaluated every time the global is called, rather than containing the
value of c(current_date) at the time you assign the global.
Then $today will give you the date number, and it will work even if
you've been running Stata since yesterday.
You can see what's "really" in $today with -macro list-:
. mac list today
today: date("`c(current_date)'","DMY")
. di $today
17751
. di %d $today
07aug2008
--Nick Winter
David Radwin wrote:
Jeph,
If you frequently need today's date formatted as a Stata date value or
some other specific format like the one below, you might find it
convenient to make a global macro like $today in your profile.do file.
The risk would be that if you leave your computer (and Stata) on
overnight, the macro would refer to an earlier date.
David
At 8:58 AM -0400 8/7/08, Jeph Herrin wrote:
Even if one isn't using it to compare with a date
variable, one usually wants to reformat before using,
and converting to a date value is the easiest way
to proceed, eg,
local today=string(date("`c(current_date)'","DMY"),"%tdCCYY.NN.DD")
--
--------------------------------------------------------------
Nicholas Winter 434.924.6994 t
Assistant Professor 434.924.3359 f
Department of Politics [email protected] e
University of Virginia faculty.virginia.edu/nwinter w
PO Box 400787, 100 Cabell Hall
Charlottesville, VA 22904
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/