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


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