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: date functions: from monthly to quarterly only through daily?


From   tashi lama <ltashi32@hotmail.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: date functions: from monthly to quarterly only through daily?
Date   Fri, 11 May 2012 15:14:10 +0000

Did you mean sth like this....

 

 

if you have dataset like following 

 

var1           date 

jan1997        1997q1

apr1997        1997q2 

jul1997

oct2010

jan2011

 

gen date=tq(1997q1)+_n-1

format %tq date 

 

Good luck 

Tashi



----------------------------------------
> From: GImpavido@imf.org
> To: statalist@hsphsun2.harvard.edu
> Date: Fri, 11 May 2012 09:39:45 -0400
> Subject: st: date functions: from monthly to quarterly only through daily?
>
> Dear all,
>
> I have a string variable containing quarterly dates in the form:
>
> . li date
>
> date
> 1. Dec1977
> 2. Mar1978
> .....etc.
>
> I want to convert it into quarterly date (Stata format). Is there a better way than the following?
>
> * begin code
> gen timem = monthly(date,"MY")
> gen timed = dofm(timem)
> gen timeq = qofd(timed)
> format timeq %tq
> * end code
>
> I could not find a -qofm()- function but ideally, I would like to get it in the first line through an the right specification of -quarterly()-
>
> Gregorio
>
>
>
> *
> * 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