Desktop User Guides > Professional > Data management scripting > Data cleaning > Data cleaning examples > Example 5: Routing-based cleaning
 
Example 5: Routing-based cleaning
Paper questionnaires often contain routing in the form of Go To instructions. For example, in the Museum example, the education question asks whether the respondent is currently enrolled in full-time education. If the response is Yes, they are asked to go to the school question, which asks for details about the type of school or college they attend.
The UNICOM Intelligence Developer Documentation Library includes a paper questionnaire (Museum.doc) that shows the routing used to collect the data. The paper questionnaire is in the form of a Word document and was created from the Museum.mdd file using UNICOM Intelligence Interviewer - Paper. However, you do not need to have UNICOM Intelligence Interviewer - Paper installed to open the document. By default, the questionnaire is installed in the [INSTALL_FOLDER]\IBM\SPSS\DataCollection\<version>\DDL\Data\Data Collection File\ folder.
This graphic is described in the surrounding text.
This example uses a Select Case statement to test the response given to the education question. If the response is No or Not answered and a regular response was selected for the school question, the education question response is set to Yes. Similarly, the response to the education question is set to No if no regular response was selected for the school question.
Event(OnNextCase, "Clean the data")
Select Case education
Case {No}
If Not (school = {Not_answered}) Then
If school.AnswerCount() > 0 Then
education = {Yes}
End If
End If
Case {Yes}
If school = {Not_answered} _
OR school.AnswerCount() < 1 Then
education = {No}
End If
Case {Not_answered}
If Not (school = {Not_answered}) Then
If school.AnswerCount() > 0 Then
education = {Yes}
End If
End If
Case Else
DataCleaning.Status = {NeedsReview}
End Select
End Event
Here is another example, an mrScriptBasic snippet, that tests the response to the visits numeric question. This question asks how many times the respondent has visited the museum previously and is only asked if he or she selected Yes in response to the before question, which asks whether he or she has visited the museum before. If the response to the visits question is within the valid range (1-99), the response to the before question is automatically set to Yes.
Event(OnNextCase, "Clean the data")
   If visits is not Null then
      If (visits > 0) And (visits < 100) Then
         before = {Yes}
      Else
         visits = 0
         before = {No}
      End If
   End If
End Event
Requirements
UNICOM Intelligence Professional
See
Data cleaning examples