Statalist The Stata Listserver


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

st: Re: tosql datatypes


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: Re: tosql datatypes
Date   Wed, 13 Jun 2007 06:54:17 -0400

I am not sure what convenient syntax could be used to achieve this. For instance,

webuse auto
gen long priceyen=100*price

will create a long int, which is probably what you want large integers to be represented as in SQL. But if you just use generate without specifying datatype, it would make it a float. In this dataset, you cannot just treat floats as longs, as -headroom- would then be mangled. I suppose you could have as many options as there are SQL datatypes, and allow something like

tosql, table(junk) cre int(...) bigint(...) float(....) double( ...)

providing for varlists with wildcards in each case. Would that make sense? Variables not listed in any of the varlists would take on their Stata datatypes.


Kit Baum, Boston College Economics and DIW Berlin
http://ideas.repec.org/e/pba1.html
An Introduction to Modern Econometrics Using Stata:
http://www.stata-press.com/books/imeus.html


On Jun 13, 2007, at 2:33 AM, Henri wrote:


tosql writes datatypes for variables when creating a table creation script.
But it uses the Stata datatypes for this, not the sql datatypes. I have a
column of integers, some around 36000. Stata treats this as float, but this
has a different meaning in sql. This is inconvenient as you will need
conversions or casts in the program using the sql database to make sure that
computations won't fail on the datatype.

Is there a way to improve on this? For instance via an interface to tosql
that allows for overruling the type of certain columns (or all at once).
*
*   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