Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Transfer of value labels: SQL data to Stata


From   Phil Schumm <[email protected]>
To   [email protected]
Subject   Re: st: Transfer of value labels: SQL data to Stata
Date   Tue, 25 Jan 2005 14:51:26 -0600

At 3:48 PM +0000 1/25/05, Lopman, Benjamin A wrote:
Transferring the data itself is of course no problem through an ODBC
connection.  The problem is handling the value labels.  (The variable
labels are also tricky but not such a major issue).  The problem is
mainly with the categorical variables and is as follows:

In Access (or any other database, as far as I am aware) the labels are
stored in a separate table.  For example, 1 and 2 are stored in a data
table and the  corresponding Male and Female labels are stored in a
second "lookup" table.  That is not how Stata or SPSS stores labels, so
when the data is brought back into one of those packages, the value
labels are lost.  I want to retain the numerical data and retain the
labels.  I am concerned about this because the dataset is so large  that
I don't want to have difficult to interpret  numerical data when the
data is shared with other analysts.

I'm not aware of any existing way to do this automatically; note that such a method would need to be able to figure out that a particular column in the "lookup" table contained string labels for a particular numeric column in the data table, and this might be difficult (if not impossible) to do in any generalized way. If it were me, I'd look to see if the lookup tables are linked to the data table via foreign keys. If so, then you could use the presence of such relationships to establish the correspondence between a particular column in the data table and the table containing its "value label". And if the lookup tables all use the same names for their two columns (e.g., "code" and "label"), then you could programmatically use the records in each table to build Stata code defining a value label and attaching that label to the corresponding variable(s). This code could then be run on the data extracted from the data table via ODBC.


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