Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

Re: st: do-file arguments acting weird

From   Nick Cox <>
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"

. di %10s "a"


On Wed, Aug 1, 2012 at 12:51 PM, Cohen, Elan <> 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:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index