Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Using date locals with -tin()-


From   Michael Hanson <mshanson@mac.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Using date locals with -tin()-
Date   Tue, 09 Jun 2009 00:50:55 -0400

I would like to get the -tin()- function to recognize the current date, such as in the example proposed below. If you run this example today (as in 2009-Jun-09), the first three list commands should yield the same results, while the last does not work due to a syntax error. I'm guessing that is because `today' evaluates to 18057 instead of 09jun2009 in the -tin()- function (for today, that is), but I'm not sure. Suggestions on how to use (some form of) the local macro `today' inside the -tin()- function would be appreciated.


// begin example code

// Define today
local today = date(c(current_date),"DMY")
disp `today'
disp %td `today'

// Create synthetic dataset
webuse sp500, clear
gen datenew = date + int(365.25*8)
format datenew %td
drop date
tsset datenew
order datenew
drop if tin(01jul2009,)

// Display data
list in -15/l                // OK
list if datenew >= `today'   // OK
list if tin(09jun2009,)      // OK
list if tin(`today',)        // Error


// end example code


Thanks in advance for any assistance.

-- Mike

*
*   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/



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