Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Problem with the time


From   Guido Lüchters <guidoluechters@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Problem with the time
Date   Wed, 13 Apr 2011 17:27:31 +0200

Many many thanks

completely understood

So the internal integer is not an absolute value
like date(1951,12,31) from excel
rather than in the metric of the number-to-date-unit: i.e. "month" in
case of ym()
so the units must fit like

yofd(mdy(1,1,1951))





On Wed, Apr 13, 2011 at 5:03 PM, Nick Cox <njcoxstata@gmail.com> wrote:
> Yes.
>
> ym(1951,1) is -108, that many months before the origin at ym(1960,1) == 0.
>
> But year() expects an argument in days. If you feed it -108, that is a
> daily date within 1959, which is what you got.
>
> So, you need to map from months to days first, as in
>
> . di year(dofm(ym(1951,1)))
> 1951
>
> There may be a simpler method of doing it, but that one works.
>
> Compare also
>
> . di yofd(mdy(1,1,1951))
> 1951
>
> Nick
>
> On Wed, Apr 13, 2011 at 3:45 PM, Guido Lüchters
> <guidoluechters@gmail.com> wrote:
>>
>> anybody knows
>>
>> why
>>
>> gen x=year(ym(1951,1))
>>
>> gives
>> 1959 ?
>
> *
> *   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/
>

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index