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, is already up and running.

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

st: RE: Remove part of a string variable

From   "Philip Ryan" <>
To   <>
Subject   st: RE: Remove part of a string variable
Date   Sun, 22 Aug 2010 02:13:40 +0930


The dofc() function which converts %tc values to %td values might help.  See
-help dates- and click on the hyperlink to -Converting date and time

* ===========
set obs 1
input str20 mytime
"21aug2005 15:21:22"
gen double cx = clock(mytime, "DMYhms")
format cx %tc
* the above gives a (formatted) double precision observation on date and

gen long dx=dofc(cx)
format dx %td
* ==========


Philip Ryan
Professor and Director
Data Management & Analysis Centre
Discipline of Public Health
University of Adelaide

T: +61 8  83033570
F: +61 8  82234075

-----Original Message-----
[] On Behalf Of Beatrice Crozza
Sent: Sunday, 22 August 2010 1:27 AM
To: statalist
Subject: st: Remove part of a string variable

Dear All,

when I upload my data into Stata from my Access file (using the odbc
function) the time variable that I have becomes:

30dec1899 09:30:14

And it is in a double format.

I want to remove from my variable time the part 30dec1899.

I tried with generate splitat and with split time, p("30dec1899") but they
don't work.

Could you please help me?

Thank you very much.

*   For searches and help try:

No virus found in this incoming message.
Checked by AVG - 
Version: 8.5.441 / Virus Database: 271.1.1/3085 - Release Date: 08/21/10

*   For searches and help try:

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