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 at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: ym() date function is acting strangely


From   Gabi Huiber <ghuiber@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: ym() date function is acting strangely
Date   Thu, 15 Dec 2011 14:50:56 -0800

Thank you, everybody. Bill is right. In the do-file I was editing, I
have %td instead of %tm. I corrected, re-ran, and now all is well. My
x-axis labels now make sense.

However: I was absolutely sure that when I tried to replicate this for
the Statalist, I had typed at the command line exactly what I showed
in my previous e-mail: %tm, not %td. So, when Bill doubted me, I fired
up the do-file editor with an untitled tab, and got to work on doing
it again.

This time, the Stata do-file editor decided to fix my work by changing
%tm to % and that tiny upperscript, uppercase "TM", as in "trade
mark". I was shocked. I took a screen shot.

This only happens in a new untitled tab. When I went to the tab where
I had the original do-file with the %td, I could change it to %tm and
save over without a problem.

I guess the do-file editor treats plain text as it should if you type
it in a tab where an existing do-file is being edited; and it's
killing you with helpfulness in an untitled tab that it has not yet
associated with a do-file.

I bet this only happens on the Mac, too. All this cute overload only
happens on the Mac.

Gabi

On Thu, Dec 15, 2011 at 1:50 PM, William Gould, StataCorp LP
<wgould@stata.com> wrote:
> Gabi Huiber <ghuiber@gmail.com> writes,
>
>> I do this:
>>
>> clear
>> set obs 10
>> gen year=2010
>> gen month=_n
>> gen date1=ym(year, month)
>> format date1 %tm
>>
>> And I get this:
>>
>> year  month   date1
>> 2010  1       23aug1961
>> 2010  2       24aug1961
>> 2010  3       25aug1961
>> 2010  4       26aug1961
>> 2010  5       27aug1961
>> 2010  6       28aug1961
>> 2010  7       29aug1961
>> 2010  8       30aug1961
>> 2010  9       31aug1961
>> 2010  10      01sep1961
>>
>> How on Earth is that possible? A minute ago ym() was working fine, I swear.
>
> I suspect Gabi did not type
>
>        . format date1 %tm
>
> but instead typed
>
>        . format date1 %td
>
> If Gabi had done that, the above output is exactly what he would get.
> And all Gabi needs to do to get the correct output is now type
>
>        . format date1 %tm
>
> and he will get the correct output.  There is no problem with the -ym()-
> function.  It stored the right values, namely 600, 601, 602, ..., 609.
>
>
> -- Bill
> wgould@stata.com
> *
> *   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