-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Tuesday, 27.09.2005 at 23:23 +0900, Joseph Coveney wrote:
> > Ah, interesting: that certainly appears to work, in the sense that it
> > reads in the dates as strings.
> >
> > However, this doesn't actually give you 'proper' date variables, does
> > it? I realise one can string-splice to pull out the components of the
> > date, but that's rather tedious.
> > [excerpted]
> > Can you suggest a way to 'transparently' import these dates as 'proper'
> > date variables? Or at least a way to easily re-type the imported
> > strings as dates?
>
> Starting with a date variable imported as a string, e.g.,
>
> set obs 1
> generate str c = "2004-01-01 19:27:03" ,
>
> then you can re-type it in two lines of code:
>
> generate int c_date = date(substr(c, 1, 10), "ymd")
> format c_date %dCY-N-D
Excellent, Joseph: many thanks!
Dave.
- --
Dave Ewart
[email protected]
Computing Manager, Cancer Epidemiology Unit
Cancer Research UK / Oxford University
PGP: CC70 1883 BD92 E665 B840 118B 6E94 2CFD 694D E370
Get key from http://www.ceu.ox.ac.uk/~davee/davee-ceu-ox-ac-uk.asc
N 51.7518, W 1.2016
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFDOWnQbpQs/WlN43ARAjTBAJ4yo/D5UPFoCyLQ+4Y55V8JCa2YKgCePUQI
gVoUrl4cLGXTOzo0kdkUD5w=
=3DxY
-----END PGP SIGNATURE-----
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/