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 MM, YY varkables into a date variable


From   Michael McCulloch <mm@pinestreetfoundation.org>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Converting MM, YY varkables into a date variable
Date   Tue, 1 Feb 2011 14:58:33 -0800

Thanks Nick, for the refinement of
	-mdy(MM, 1, YY)-
Michael

On Feb 1, 2011, at 2:55 PM, Nick Cox wrote:

> I didn't see this before making my own suggestions.
> 
> Daily date variables are not at all needed if the data are monthly. In
> fact they have the marked disadvantage that after -tsset- it appears
> that roughly 29/30 of the data should be present but have been
> omitted.
> 
> But should you wish to produce daily variables for monthly data, as
> Michael is assuming, then you don't need to create a variable holding
> a constant. as -mdy(MM, 1, YY)- is perfectly legal. On the very odd
> occasions I have done this, as when some data are daily and others
> monthly, I have typically used -mdy(MM, 15, YY)- as better for
> graphical purposes.
> 
> Nick
> 
> On Tue, Feb 1, 2011 at 10:44 PM, Michael McCulloch
> <mm@pinestreetfoundation.org> >
> You can assume "day" is any day of the month, for example the 1st day.
>> 
>> *to make your variable, which we can call edate,
>>        gen DD=1
>>        gen edate = mdy(MM, DD, YY)
>> *to confirm accuracy, compare visually:
>>        list MM DD YY edate
>> 
>> On Feb 1, 2011, at 2:37 PM, Jung-eun Lee wrote:
>> 
>>> I need help with converting month and year variables into a date variable so that I can use it for a time-series analysis.
>>> Year variable: YY (looks like 1992, 1993, 1994...)
>>> Month variable: MM (looks like 1, 2, 3, 4...)
> 
> *
> *   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/


Best wishes,

Michael McCulloch, LAc MPH PhD
Pine Street Foundation
124 Pine Street
San Anselmo, CA 94960-2674
tel:	415-407-1357
fax: 	206-338-2391


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