Statalist


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

Re: st: handling missing values


From   "Michael I. Lichter" <mlichter@buffalo.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: handling missing values
Date   Mon, 02 Mar 2009 15:24:04 -0500

Jillian,

If I understand you correctly, what you want is the following. Supposing that 1 = yes, 2 = no, 7 = dk, and 9 = ref (or something along those lines):

clonevar q2r = q2
replace q2r = q1 if ((q2r == .) & (q1 > 1)).

The parentheses are optional, and the clonevar is to keep you from clobbering your original q2 variable. Be sure to check first for cases where q1==no & q2==yes, etc., which might indicate data entry errors or problems with people not following skip patterns properly.

You would do virtually the same thing in SPSS; SPSS gives you no particular advantage in this instance.

What SPSS has that every other language lacks (to my knowledge) is the ability to assign specific values or ranges to missing without changing the content of the underlying variable. That is, you can tell SPSS that "9" is missing, and SPSS will treat every "9" in the variable as missing without you having to change all of the 9s to "." SPSS, however, cannot treat missing values on one variable differently conditional on values of a second variable.

Michael

Jillian Flight wrote:
Hi there,
I am working on a survey data recode and wanted to see if there is an easy
way to handle missing values.   For instance, if question 1 asks whether or
not respondent used cocaine in lifetime - and the responses are yes, no,
don't know and refused.  Question 2 (have you used in past 12 months -
response choices yes, no, dk, ref )  however is asked only of those who
said yes to question 1 - the no, dk, and refused responses from Question 1
are missing - - is there a quick and easy way to recode question 2 so that
it is among the total population - ie. the missing values that are a result
of respondents saying "no" to question 1 being coded into the "no" of
question 2 and the dk and refused choices from question 1 which are now
missing in question 2 - having them coded into the dk and refused of
question 2?  I am currently doing this via a very convaluded method and a
colleague told me spss is much easier for handling missing values when
recoding data such as this, but I'm thinking there must be an easy way of
doing this in stata.

Thanks


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

--
Michael I. Lichter, Ph.D.
Research Assistant Professor & NRSA Fellow
UB Department of Family Medicine / Primary Care Research Institute
UB Clinical Center, 462 Grider Street, Buffalo, NY 14215
Office: CC 125 / Phone: 716-898-4751 / E-Mail: mlichter@buffalo.edu

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index