Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: dates in the 'if' condition


From   Phil Clayton <philclayton@internode.on.net>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: dates in the 'if' condition
Date   Tue, 9 Aug 2011 23:09:58 +0930

You can use the tq() function:
keep if time==tq(1997-4)

See -help dates_and_times-

Phil

On 09/08/2011, at 10:58 PM, Tomas.Konecny@cnb.cz wrote:

> Hi,
> 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                    
> 
> keep if time==1997q4
> 1997q4 invalid name
> r(198);
> 
> keep if time=="1997q4"
> type mismatch
> r(109);
> 
> Thank you,
> Tomas 
> 
> *
> *   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index