蓝色 发表于 2013-3-12 01:02 
. clear
. input ///
我自己研究了一下,不知道为什么,我将数据copy以后再复制出来有些数就变了,我在这个拷贝数据上进行的操作所以发生了数据错误。我再原始列上操作就好了。
另外,我帮版主补充一下,我看了tostring 和 substr 的help 才最后得到答案了,仅对于我这个案例:(由于time有5为和6位的区别,所以在做H的时候需要进行两步)
.tostring transaction_date, generate(date)
date generated as str8
. tostring transaction_time, generate(time)
time generated as str6
. gen Y=real(substr(date,1,4))
. gen Mon=real(substr(date,5,2))
. gen D=real(substr(date,7,2))
. gen H=0
. replace H=real(substr(time,-6,2))
(4427131 real changes made, 1527024 to missing)
. replace H=real(substr(time,-5,1)) if H==.
(1527024 real changes made)
. gen M=real(substr(time,-4,2))
. gen S=real(substr(time,-2,2))
.list date time Y Mon D H M S
.
.
.
4425776. | 20121031 143728 2012 10 31 14 37 28 |
4425777. | 20121031 143728 2012 10 31 14 37 28 |
4425778. | 20121031 143728 2012 10 31 14 37 28 |
4425779. | 20121031 143729 2012 10 31 14 37 29 |
4425780. | 20121031 143729 2012 10 31 14 37 29 |
|----------------------------------------------------|
4425781. | 20121031 143957 2012 10 31 14 39 57 |
4425782. | 20121031 92133 2012 10 31 9 21 33 |
4425783. | 20121031 92133 2012 10 31 9 21 33 |
4425784. | 20121031 144006 2012 10 31 14 40 6 |
4425785. | 20121031 92133 2012 10 31 9 21 33 |
|----------------------------------------------------|
4425786. | 20121031 144053 2012 10 31 14 40 53 |
4425787. | 20121031 92133 2012 10 31 9 21 33 |
4425788. | 20121031 144053 2012 10 31 14 40 53 |
4425789. | 20121031 92133 2012 10 31 9 21 33 |
4425790. | 20121031 144053 2012 10 31 14 40 53 |
|----------------------------------------------------|
4425791. | 20121031 92133 2012 10 31 9 21 33 |
4425792. | 20121031 144053 2012 10 31 14 40 53 |
4425793. | 20121031 92133 2012 10 31 9 21 33 |
4425794. | 20121031 92133 2012 10 31 9 21 33 |
4425795. | 20121031 142728 2012 10 31 14 27 28 |
|----------------------------------------------------|
4425796. | 20121031 142728 2012 10 31 14 27 28 |
4425797. | 20121031 142729 2012 10 31 14 27 29 |
4425798. | 20121031 144053 2012 10 31 14 40 53 |
4425799. | 20121031 144054 2012 10 31 14 40 54 |
4425800. | 20121031 144858 2012 10 31 14 48 58 |
|----------------------------------------------------|
4425801. | 20121031 144900 2012 10 31 14 49 0 |
4425802. | 20121031 144902 2012 10 31 14 49 2 |
4425803. | 20121031 143005 2012 10 31 14 30 5 |
4425804. | 20121031 143726 2012 10 31 14 37 26 |
4425805. | 20121031 143727 2012 10 31 14 37 27 |
|----------------------------------------------------|
4425806. | 20121031 112413 2012 10 31 11 24 13 |
4425807. | 20121031 112629 2012 10 31 11 26 29 |
4425808. | 20121031 145928 2012 10 31 14 59 28 |
4425809. | 20121031 134448 2012 10 31 13 44 48 |
4425810. | 20121031 135229 2012 10 31 13 52 29 |
|----------------------------------------------------|
4425811. | 20121031 145939 2012 10 31 14 59 39 |
4425812. | 20121031 144534 2012 10 31 14 45 34 |
4425813. | 20121031 144944 2012 10 31 14 49 44 |
4425814. | 20121031 145344 2012 10 31 14 53 44 |
4425815. | 20121031 145631 2012 10 31 14 56 31 |
|----------------------------------------------------|
4425816. | 20121031 94905 2012 10 31 9 49 5 |
4425817. | 20121031 91010 2012 10 31 9 10 10 |
4425818. | 20121031 144231 2012 10 31 14 42 31 |
4425819. | 20121031 93910 2012 10 31 9 39 10 |
4425820. | 20121031 93516 2012 10 31 9 35 16 |
|----------------------------------------------------|
4425821. | 20121031 111518 2012 10 31 11 15 18 |
.
.
.
.
.
再次感谢老版主给的启示!