Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: dates in the 'if' condition


From   Nick Sanders <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: dates in the 'if' condition
Date   Wed, 10 Aug 2011 08:54:06 -0700

For greater/less that and equal statements, you can also use the format of the variable in the reference, e.g. for month formatted dates

keep if time > tm(2002m2)

or for quarter

keep if time > tq(2002q2)

Note this doesn't work for date references within graph code (such as in xline under twoway).

Sent from my iPhone - please excuse typos and/or brevity.

On Aug 10, 2011, at 6:20 AM, Christopher Baum <[email protected]> wrote:

> <>
> On Aug 10, 2011, at 2:33 AM, Tomas wrote:
> 
>> I have not used Stata in time-series context before and would like to ask
>> a rather simple thing. Having the time variable in a %tq format, it displays the date label but the underlying value
>> is a number. I have tried to condition with the `if' statement referring to the label instead of the underlying value, but to no avail. Is there any way to do so?
>> Here is an example:
>>             storage  display     value
>> variable name   type   format      label      variable label
>> - --------------------------------------------------------------------------------------------------------------------------------------
>> time          float  %tq              
> 
> If time is the variable by which the data are tsset,
> 
> keep if tin(1997q4, 1997q4)
> 
> should work fine.
> 
> Kit Baum   |   Boston College Economics & DIW Berlin   |   http://ideas.repec.org/e/pba1.html
>                              An Introduction to Stata Programming  |   http://www.stata-press.com/books/isp.html
>   An Introduction to Modern Econometrics Using Stata  |   http://www.stata-press.com/books/imeus.html
> 
> 
> 
> 
> *
> *   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/

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index