Statalist


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

st: Too many decimal places for ODBC


From   Gawrich Stefan <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: Too many decimal places for ODBC
Date   Tue, 13 May 2008 18:01:11 +0200

Hi statalisters,

I'm trying to establish ODBC-connections between Stata and a Firebird
database (V: 2.1) under Win XP.
The available ODBC-drivers are a bit outdated and not well documented. So I
had to find out more or less by trial and error why I couldn't export float
and double vars. The error is not a decimal point/comma issue but a issue of
decimal places.
The ODBC-driver is only capable of 18 decimal places while stata exports 20.


So what happens: 
gen float age = 6
odbc insert age , table(s1) dsn(firebird) create sqlshow

** ...leads to:

CREATE TABLE s1 (age FLOAT)
INSERT INTO s1 (age) VALUES (6.00000000000000000000)
[ODBC Firebird Driver][Firebird]Dynamic SQL Error
SQL error code = -104 Token unknown - line 1, column 30 6

**********************************************************

Cutting a value to 18 decimal places works: 

odbc exec("insert into s1 (age) VALUES (6.123456789012345678)"),
dsn(firebird) 

** ...leads to:
insert into s1 (age) VALUES (6.123456789012345678)


****

My question:

Is there any way to reduce decimal places before ODBC export inside Stata (I
need no more than 2 or 3 decimal places)
 
There are workarounds (like export as string or export multiplied with 1000
as an integer - with reconversion inside the database) but these are
burdensome and error-prone in routine use.


Best wishes

Stefan Gawrich
Dillenburg
Germany








*
*   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