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 on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: Regarding Dates in String format


From   Michael Stewart <michaelstewartresearch@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Regarding Dates in String format
Date   Tue, 27 Nov 2012 20:36:37 -0500

thanks a lot nick for your help.


On Tue, Nov 27, 2012 at 8:19 PM, Nick Cox <njcoxstata@gmail.com> wrote:
> If you had several such date variables,
>
> tostring <varlist>, format(%td)
>
> or
>
> tostring <varlist>, usedisplayformat
>
> could help.
>
> On Wed, Nov 28, 2012 at 1:16 AM, Nick Cox <njcoxstata@gmail.com> wrote:
>> Use -string()- function with a format second argument. What is often
>> missed is that the format must be a numeric format (dates are included
>> here).
>>
>> . di string(mdy(6,23,2010), "%td")
>> 23jun2010
>>
>> gen <strdate> = string(<numdate>, "%td")
>>
>> -tostring- is just a wrapper for the above. It is only a better idea
>> if you want to do this with several variables.
>>
>> Nick
>>
>> On Wed, Nov 28, 2012 at 1:07 AM, Michael Stewart
>> <michaelstewartresearch@gmail.com> wrote:
>>
>>> I have a problem with dates.My dates are in regular format(%td) like 23jun2010 .
>>> I want to convert them to a string variable looking exactly like
>>> "23jun2010" but as string variable.
>>> As I  try to covert it into a string variable using tostring  command,
>>> I get a number in string format (like 7326 ect ) but cant get the
>>> exact format (like 23jun2010).
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/



-- 
Thank you ,
Yours Sincerely,
Mike.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index