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: changing date format
From
"Michael N. Mitchell" <[email protected]>
To
[email protected]
Subject
Re: st: changing date format
Date
Sat, 04 Sep 2010 20:15:10 -0700
Dear Mike
You were so close to having it right... here is how you can do this...
clear
input str8 tradedate
20010102
20010103
20010104
20010105
20010106
20010107
end
. generate date = date(tradedate, "YMD")
. format date %td
. list
+----------------------+
| traded~e date |
|----------------------|
1. | 20010102 02jan2001 |
2. | 20010103 03jan2001 |
3. | 20010104 04jan2001 |
4. | 20010105 05jan2001 |
5. | 20010106 06jan2001 |
|----------------------|
6. | 20010107 07jan2001 |
+----------------------+
I hope that helps,
Best regards,
Michael N. Mitchell
Data Management Using Stata - http://www.stata.com/bookstore/dmus.html
A Visual Guide to Stata Graphics - http://www.stata.com/bookstore/vgsg.html
Stata tidbit of the week - http://www.MichaelNormanMitchell.com
On 2010-09-04 7.11 PM, Mike Kim wrote:
Dear Statalisters,
I imported daily stock data from CRSP. The data shows date like this:
tradedate
20010102
20010103
20010104
20010105
20010106
20010107
......
Neither of the following commands works:
- format tradedate %td
- gen date=date(tradedate, "MDY")
I split tradedae into month, day, year in excel, imported into Stata, and
used the following command to combine them.
- gen date=mdy(month,day,year)
Is there any way I can change tradedate into Stata date format without using
excel?
Thank you in advance,
Mike.
*
* 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/
*
* 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/