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: -label define- and -replace- when a variable may be missing
From
Michael McCulloch <[email protected]>
To
[email protected]
Subject
st: -label define- and -replace- when a variable may be missing
Date
Sat, 8 Mar 2014 18:30:05 -0800
Hello,
I am cleaning data for a survey, in which for one question, respondents were asked where they got their training.
There are 9 possible answers for this question, but as I monitor survey data coming in, some may have missing values.
The online survey instrument creates the variables as they are filled in:
what_types_of_training_did___1
what_types_of_training_did___2, and so on up to
what_types_of_training_did___9
In order to create reports but not have my do-file stopped by a missing (not yet defined) variable, how can I modify the following code?
gen training=.
replace training=1 if what_types_of_training_did___1==1
replace training=2 if what_types_of_training_did___2==1
replace training=3 if what_types_of_training_did___3==1
lab def lab_train 1 "Accredited US School" ///
2 "Accredited School outside US" ///
3 "Unaccredited US School", modify
Best wishes,
Michael McCulloch
--
Pine Street Foundation, since 1989
124 Pine Street | San Anselmo | California | 94960-2674
P: (415) 407-1357 | F: (206) 338-2391 | http://www.PineStreetFoundation.org
*
* 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/