Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: converting dates formatted with dots


From   Ana Gabriela Guerrero Serdan <[email protected]>
To   [email protected]
Subject   st: converting dates formatted with dots
Date   Mon, 29 Jan 2007 03:18:23 -0800 (PST)

Hi, 
 
I want to convert a variable that includes dates as
follows: day.month.year (e.g. 1.4.2005) into three
different variables for day, month and year (day=1,
month=4,year=2005)
 
I have tried the date commands but since I have dots
stata does not recognize them. 
 
. list sdate incident sex agecat
+-------------------------------------------+
sdate   incident       sex    agecat 
-------------------------------------------
1.   20.3.2003       x007   unknown   Unknown 
2.   20.3.2003       x038      male   Unknown 
3.   20.3.2003       x038      male   Unknown 
4.   20.3.2003       x038      male     child 
5.   20.3.2003       x038    female     child 
-------------------------------------------
6.   20.3.2003       x038   unknown   Unknown 
7.   20.3.2003       x038   unknown   Unknown 
8.   20.3.2003       x038   unknown   Unknown 
9.   20.3.2003       x038   unknown   Unknown 
10.   20.3.2003       x038   unknown   Unknown 
-------------------------------------------
11.   20.3.2003       x038   unknown   Unknown 
12.   20.3.2003       x038   unknown   Unknown 
13.   20.3.2003       x038   unknown   Unknown 
14.   20.3.2003       x038   unknown   Unknown 
15.   20.3.2003       x038   unknown   Unknown 
-------------------------------------------
16.   20.3.2003       x038   unknown   Unknown 
17.   20.3.2003       x038   unknown   Unknown 
etc... 


Break--
r(1);
. generate date=year(sdate)
type mismatch
r(109);

 
Any ideas? 
 
thanks, 
Gaby 
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index