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   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Converting MM, YY varkables into a date variable
Date   Tue, 1 Feb 2011 22:46:38 +0000

"Looks like" does not pin it down, but if they really are numeric
variables then

gen date = ym(YY, MM)

will work and if they really are string variables then

gen date = ym(real(YY), real(MM))

will work. You'd want to format that new variable e.g. minimally

format date %tm

Nick

On Tue, Feb 1, 2011 at 10:37 PM, Jung-eun Lee <tinymoon@yahoo.com> wrote:
> Hello,
> 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/


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