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   Guido Lüchters <[email protected]>
To   [email protected]
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 <[email protected]> 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
> <[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/
>

*
*   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