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   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Problem with the time
Date   Wed, 13 Apr 2011 16:03:53 +0100

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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index