Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: run-together dates [was :... syntax; option real & varname ]

From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: run-together dates [was :... syntax; option real & varname ]
Date   Thu, 15 Aug 2002 16:41:09 +0100


Quick question.

I have a numeric variable (float) of the form:  19460515

The variable actually refers to the date, May 15, 1946.  Truncating
concatenating functions appear to operate only on string variables.
approach can I use to change this to the correct date?


Manual discussion: [U] p.287

FAQ discussion:

How do I convert date variables into Stata elapsed dates when
the numbers run together, like 4151999?

First principles approach:

. gen year = real(substr(string(date),1,4))
. gen month = real(substr(string(date),5,2))
. gen day = real(substr(string(date),7,2)

Canned solution:

. ssc inst todate
. todate date, p(yyyymmdd) g(sdate)

Recommendation: use the resources available.

[email protected]

*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index