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

st: converting dates from Excel .csv file

From   Michael McCulloch <[email protected]>
To   Statalist <[email protected]>
Subject   st: converting dates from Excel .csv file
Date   Sat, 23 Aug 2008 19:14:20 -0700

I have dates in an Excel *.csv file as:


I wrote the following code to convert to Stata date:
	gen str date_year = substr(date, -2,.)
	gen str date_month = substr(date, 1, 2)
	gen str date_day = substr(date, 4, 2)
	destring  date_year date_month date_day, replace
	list date date_month date_day date_year

However, when I import the *.csv file, the leading zeroes are dropped 
from months 1-9.
Is there a way to solve this in Stata, without having to create 
separate columns for m, d, and y in Excel?


Best wishes,
Michael McCulloch

Pine Street Foundation
124 Pine St., San Anselmo, CA 94960-2674
Tel:	(415) 407-1357
Fax:	(415) 485-1065
[email protected]

*   For searches and help try:

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