Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: Importing Data and Defining Variable Types


From   Erika Kociolek <[email protected]>
To   [email protected]
Subject   st: Importing Data and Defining Variable Types
Date   Tue, 7 May 2013 17:59:22 -0700

Hi there,

I am working with a large number of datasets that have some variables
in common. I'll use the two datasets below as an example to illustrate
my question:

State1.dta

var1 var2
.         1
1        .
4        .
13     2


State2.dta

var1 var3
          .
1'       2
3        3
4        4

As you can see above, the files State1 and State2 have var1 in common.
I would like to append the State1 and State2 files together to create
a master file containing data for both states (some fields will be
blank because those datapoints may not have been collected for a given
state).

Due to some issues with the source datasets, in some of the State
files, var1 is a string (as is the case with State2) and in others,
var1 is numeric (as is the case with State1). Since the variable types
are different, I cannot append one file to the other.

My question: is there is any way to define that certain variables  be
imported as a particular type of variable (such as a string variable),
instead of having to import files and then generate new string
variables using a function like "tostring"? I'd like to be able to get
the variables in all .dta files defined consistently so it is easy to
append them to a master datafile.

Thanks!
Erika
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index