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]
st: convert a date variable to a string variable with daynames
From
Haluk Vahaboglu <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: convert a date variable to a string variable with daynames
Date
Wed, 7 Aug 2013 09:09:51 +0000
Dear Statalisters,
I am using Stata 12.1 MP for Linux 64 bit.
I want to convert a date variable to a string variable. This can be achieved by "-stimeofday-" command (by Nicholas J. Cox,). Below; date variable, command and the output can be found.
variable:
d
01.January.2013
02.January.2013
03.January.2013
04.January.2013
des
d float %td..
-------------------------
stimeofday d, gen(stime) n(d) s(d h) dformat(%dd_m_CY) sformat(%02.0f)
d stime
01.January.2013 1 Jan 2013 00
02.January.2013 2 Jan 2013 00
03.January.2013 3 Jan 2013 00
04.January.2013 4 Jan 2013 00
des
d float %td..
stime str14 %14s d (days hours)
-----------------------------
I get a string variable as "day month year h".
My question is this:
Can I get an output (a string variable) displaying as "day month year dayname" (1 Jan 2013 Tuesday).
Any help will be appreciated
Haluk Vahaboğlu
*
* 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/