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

Re: st: survey completion flag


From   [email protected] (William Gould, Stata)
To   [email protected]
Subject   Re: st: survey completion flag
Date   Fri, 18 Feb 2005 08:36:34 -0600

Marilyn Matevia <[email protected]> asked, 

> with many nested skip patterns, and about 2200 respondents.  After working
> out the skip codes, I still have many "missing" observations for some items,
> and figure these are due to incomplete surveys.  I want to create some kind
> of "completion flag" to see which respondents make it to the end of the
> survey, and - if they don't - to see which question is the respondent's last
> (which is complicated by the skip patterns).

One solution is to create a set of variable that indicate which questions a
respondent should have answered, compare that with results, and then work
backwards.

Step 1:  Which questions should have been answered
--------------------------------------------------

Due to the skip patterns, questions occur in blocks.  Let's call the 
blocks B1, B2, ...

What we are going to do is create a set of dummy varibles, sB1, sB2, ..., 
corresponding to the blocks.  If a respondent should have answered the 
questions in block i, sB<i> will be 1; otherwise, it will be 0.

We start by setting all sB<i> variables to zero.  To fix ideas, we will
pretend there are 23 blocks.  We start by setting all sB<i> variables to 0:

        . gen byte sB1 = 0 
        . gen byte sB2 = 0 
        . ...
        . gen byte sB23 = 0

or, if you prefer, 

        . forvalues i=1(1)23 {
        .  gen sB`i' = 0
        . }

Now, it is natural to assume the all respondents should have answered 
B1:
        . replace sB1 = 1

Who should have answered B2?  That depends on answers in B1.  
Assume responses to questions are in variables q1, q2, ..., q170.
Perhaps a person should have answered B2 if

        . replace sB2 = 1 if q2=="m" & q3>1 & q3<4

We proceed through the survey in this manner.  Perhaps the code for the 
last block reads

        . replace sB23 = 1 if q40==3 & q102=="5"


Step 2:  whether they answered a block
--------------------------------------

Let us now create another set of variables aB1, aB2, ..., aB23 that 
reflects whether questions were answered in a block:

        . gen byte aB1 = (q1!=. & q2!="" & q3!=.)
        . gen byte aB2 = (q4!=. & q5!=.)
        . ...
        . gen byte aB23 = (q167!="" & q168!=. & q169!=. & q170!=.


Step 3:  Compare 
----------------

A respondent has missing date for B<i> if aB<i>==0 & sB<i>==1.

        . forvalues i=1(1)23 {
        .     gen byte mB`i' = aB`i'==0 && sB`i'==1
        . }



Step 4:  Cleanup
----------------

We may not need aB<i> and sB<i> variables any more:

        . drop aB* sB*


Step 5:  Last block answered
----------------------------

        . gen lastblock = . 
        . for i=1(1)23 {
        .   replace lastblock = `i' if mB`i'==1
        . }

-- Bill
[email protected]
*
*   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