Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: Column types for ODBC

From   "Martin Weiss" <>
To   <>
Subject   st: RE: Column types for ODBC
Date   Fri, 21 May 2010 19:54:29 +0200


" Is there a way to force the create option to use 
particularl column types?"

In Stata parlance, these are data types. The whole array can be seen in
-help data_types-. -generate- accepts them as "arguments", as in -gen str10
myvar="hello"- for a string of maximum length 10.


-----Original Message-----
[] On Behalf Of Michael Ewens
Sent: Freitag, 21. Mai 2010 19:50
Subject: st: Column types for ODBC

Dear all:

I am inserting columns of Stata-formatted dates into an ODBC database 
(MySQL).  If one runs

gen date = mdy(month,year,date)
format date %td
odbc insert, dsn(datasource) t(test) u(u) create sqlshow

Stata creates a 'float' column in the new table.  If one wants to 
subsequently use this new table outside of Stata, the date information 
is effectively lost.  Is there a way to force the create option to use 
particularl column types?

My current workaround first converts the 'date' variable to a string 
'YYYYMMDD.'  The next step could be to run something like

odbc exec("ALTER TABLE test MODIFY date DATE"), dsn(datasource) u(u)

Unfortunately, this approach requires a line of code for all the date 
variables in the data.  Is there a better approach to dealing with dates 
and odbc?  Ideally, the 'datestring' option available for 'odbc load' 
would be available for 'odbc insert'.

*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index