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: do-file arguments acting weird


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: do-file arguments acting weird
Date   Wed, 1 Aug 2012 13:46:07 -0500

Elan is clearly right about the main advice here. However, there are
string formats too:

. di %20s "a"
                   a

. di %10s "a"
         a

Nick

On Wed, Aug 1, 2012 at 12:51 PM, Cohen, Elan <cohened@upmc.edu> wrote:
> Formats can only be applied to numeric items, which macro 'a' is not.  Of course, you could always convert it to numeric, then apply the format:
>
> loc a 16jun2012
> loc anum = date("`a'","DMY")
> di %tdDDMonCCYY `anum'
> di %tdCCYY-DD-NN `anum'

tashi lama
>>
>> 2. If I have a variable date with date in format %tdDDMonCCYY, I have no problem changing to other formats using ( format date %tdCCYYDDMON or format I desire). However, if I have a date in a macro, how can I change the display format. For eg.
>>
>> local a 01jan2011
>> di "`a'"
>> 01jan2011
>> if I want `a' in 2011-01-01, then
>> format `a' %tdCCYY-DD-NN (of course stata isn't happy)
*
*   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