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: converting date format


From   "Dimitriy V. Masterov" <[email protected]>
To   Statalist <[email protected]>
Subject   Re: st: converting date format
Date   Mon, 22 Jul 2013 11:38:43 -0700

If your date is stored as a string, you will need to convert it to
Stata date format first:

. gen date2=date(date,"MDY")

. format date2 %td

Then convert it to year-quarter like this:

. gen yq = qofd(date2)

. format yq %tq


On Mon, Jul 22, 2013 at 11:29 AM, Bosch, Darrell <[email protected]> wrote:
>
>
> I have a dataset with data entered by quarter from 1947 to 2012.  The following date variable indicates the dates of each observation (month/day/year).
> 01/01/1947
> 04/01/1947
> 07/01/1947
> ...
> ...
> 01/01/2012
> 04/01/2012
> 07/01/2012
> 10/01/2012
>
> I would like to convert the dates to quarters as follows:
> 1947q1
> 1947q2
> 1947q3
> Etc.
>
> Any suggestions on how to do this would be appreciated.
>
> Darrell Bosch
>
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index