IBM SPSS Data Collection – List of question names in an external file

imageDC2

In order to perform certain operations, we may want to retrieve the list of all the names of the questions present in our data (MDD file).
We could go over that MDD file via “ IBM SPSS Data Collection Base Professional ” and list all the questions but that would be quite tedious. So we will prefer to use a script that will automatically browse our MDD and list all the names of the questions in an external text file.

To do this, simply use the following few lines of code in an MRS script (only the parameters “InputMDD” and “OutputFile” will be modified):

Dim V, Out, InputMDD, OutputFile

InputMDD = "mesDonnees.mdd"
OutputFile = "MyVariablesList.txt"

Set Out = CreateObject("Scripting.FileSystemObject").CreateTextFile(OutputFile)

With CreateObject("MDM.Document")
        .Open(InputMDD)
        For Each V In .Variables
              Out.WriteLine(V.Name)
        Next
End With

Out.Close()

Then we get a file “MyVariablesList.txt” which contains something in the following format:

respondent_id
status
sexe
age
csp
q1
q2
q3



Our next article on “IBM SPSS Data Collection” will focus on the statistical tests
and how to automatically specify the columns to test.

Leave a Reply

Your email address will not be published. Required fields are marked *