Is there a Stata tool to convert the string variables created by DBMS/Copy
that contain the value label information back to value labels after
transferring data from SPSS to Stata?
When I have an SPSS datafile that contains variables with value labels
and I use DBMS/Copy to create a Stata datafile, DBMS/Copy asks if I want
string variables created for each variable that has a value label. The
downside to this is that it nearly doubles the number of variables in
my dataset and it more than doubles the size of the datafile.
I wrote a Stata program to convert these variables back to value labels
because -encode- does not necessarily generate the same numeric values
as the original numeric variables. I spent quite a bit of time Googling
around for such a tool and didn't find one. Stat/Transfer seems to just
make value labels in the Stata datafile, which is great. I don't have
SPSS available to me.
I'm wondering how or if people deal with this problem and if my program
would be of interest to others.
This looks like one reason why I developed -sencode- (downloadable from
SSC). -sencode- ("super -encode-") encodes string variables to labelled
numeric variables in an order defined by the user, which defaults to the
order of appearance of the string value in the dataset, but which can be
set to some other order using the -gsort()- option. There is also a
-manyto1- option, allowing the mapping from numeric values to string labels
to be many-to-one, and a -replace- option, allowing the output labelled
numeric variable to replace the input string variable, taking its name,
variable label, characteristics and position in the data set. More about
the use of -sencode- can be found in Newson (2003) and Newson (2004), both
downloadable from my website, which can be found in Stata by typing