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: Combining two data variables (month and year)


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Combining two data variables (month and year)
Date   Wed, 7 Aug 2013 09:13:09 +0100

What I wrote was not completely correct, so I will rephrase it.

If you have a day variable, -mdy(month, day, year)- is a fine way to
produce daily dates.

If you want a monthly date, -mdy()- is not a good idea. -ym()- is the
better way to combine year and month information.

Nick
[email protected]


On 6 August 2013 17:36, Nick Cox <[email protected]> wrote:
> No; this isn't crazy, but it's usually a bad idea.
>
> Regardless of whether you actually have a day variable -- you could
> fudge that by using 1 or 15  instead -- you will end with daily dates
> and lots of gaps. That's awkward for almost everything that might
> follow.
>
> If you have monthly dates, you want monthly dates and should use -ym()-.
>
> Nick
> [email protected]
>
>
> On 6 August 2013 17:31, Najib Mozahem <[email protected]> wrote:
>> if I understand correctly, you have a month_variable and a year_variable and want one date variable to contain both. I used the gen myvar = mdy(month_var, day_var, year_var) command for that.
>>
>> Najib
>>
>> On Aug 6, 2013, at 7:01 PM, MCar wrote:
>>
>>> Dear Statalist users:
>>>
>>> I need to combine two numeric variables into one variable.  The first
>>> variable is the month and the second variable is the year.
>>>
>>> Does anybody know how to do this?
*
*   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