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

st: variable


From   Thomas Speidel <thomassp@cancerboard.ab.ca>
To   statalist@hsphsun2.harvard.edu
Subject   st: variable
Date   Fri, 08 Apr 2005 09:47:08 -0600

Jorge,

Assuming your Var1 is numeric, try this:

. tostring var1, gen(date)
. gen day=substr(date,1,2)
. gen month=substr(date, 3, 2)
. gen year=substr(date, 5, 8)

At some point you may need to go back to the full date:
. destring day, gen(day1)
. destring month, gen(month1)
. destring year, gen(year1)
. gen date2=mdy(month1, day1, year1)
. format date2 %d

Hope this helps,
Thomas


--
Thomas Speidel
Statistical Associate
Department of Oncology
Tom Baker Cancer Centre
1331 - 29th Street N.W.
Calgary, AB, T2N 4N4

Tel. (403) 944-4135
Email: thomassp@cancerboard.ab.ca



This e-mail and any attachments may contain confidential and
privileged information. If you are not the intended recipient,
please notify the sender immediately by return e-mail, delete this
e-mail and destroy any copies. Any dissemination or use of this
information by a person other than the intended recipient is
unauthorized and may be illegal.
*
*   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/



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