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: Problem with the time


From   Nick Cox <[email protected]>
To   [email protected]
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
<[email protected]> 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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index