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: dates question


From   Michael Eisenberg <[email protected]>
To   [email protected]
Subject   Re: st: dates question
Date   Mon, 8 Oct 2012 08:45:29 -0700

Brilliant.  Thanks so much!

On Mon, Oct 8, 2012 at 2:12 AM, Nick Cox <[email protected]> wrote:
> See [U] 24 for a brief introduction and -help dates and times- for
> fuller detail.
>
> If your variables are all numeric then
>
> gen dailydate = mdy(injmo, injday. injyr)
>
> will produce a daily date variable. Then
>
> format dailydate %td
>
> or
>
> formal dailydate %d
>
> will assign a default format for daily dates. You can tune that format
> using recipes given in the -help-.
>
> Note that (a) having a values in a variable that Stata will interpret
> as dates as you want and (b) assigning a format that displays a date
> variable as a recognisable date are quite separate in principle, as
> shown by the separate commands above.
>
> Nick
>
> On Mon, Oct 8, 2012 at 9:37 AM, Michael Eisenberg
> <[email protected]> wrote:
>
>> I have what I hope will be a simple question regarding dates.
>>
>> I have separate columns for day of injury, month of injury, and year
>> of injury.  How can I merge these into one variable in date format?
>>
>> For example
>> injmo   03
>> injday  29
>> injyr  2001
>>
>> newvar 29mar2001
>> or
>> newvar 15063
> *
> *   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