Levels in Companion Reflect
You can make repeated questions or block of questions into separate levels of data using QPSMR CL. Each repeat is then written as a separate record to the internal data file used by Companion Reflect. This avoids having to use overlaid tables because each repeat will be added into the table automatically.
Companion Reflect knows that levels are present when it finds a variable called LEVEL in the data. The value of the LEVEL variable tells Reflect which level of data is required for a table.
If we have a questionnaire which asks for some general information and also asks a block of questions about 3 separate occasions (3 repeats) then there will be 4 records for analysis. Each questionnaire will have a LEVEL/1 record that contains general information about the person being interviewed and 3 LEVEL/2 records for the repeats. The first LEVEL/2 record can in theory be combined with the LEVEL/1 record which is why LEVEL must a multi-coded
It is the responsibility of the user of Companion Reflect to choose an appropriate level for the questions being tabulated, see Repeats overview. For this to be practical the person who makes the Reflect files should label all level 2 questions as such in the XT (variable title). We suggest you do this by putting “Level 2. ” in front of the relevant question texts.
Complicated surveys may have more than 2 levels, which may be separate repeats or sub-levels of other repeats.
Convert an STP for Companion Reflect
To convert a project for Companion Reflect with levels here are some guidelines. Use the Companion [File] [Export project as] [CL script STP]. The STP then need to changed:
Change CEP run control parameter to CE. Delete the run control parameter TIDY. After the format settings at the top of the data stage add the empty level variable:
dm $level=f,f, xt='Level', x='General,Occasions',
At the end of the data stage, before FINISH DATA you need to add:
- Define the level 2 variables for the first level and write the record
- Do the same for the other repeats
- Write the level 1 record
For a simple project with 3 questions for each repeat, this might look something like:
go out to @repeat1, zero to finish, go out to @repeat2, zero to finish, go out to @repeat3, zero to finish, go to @end, @repeat1, ds $brand=$brand1, xt='Level 2. Brand', x=$brand1, dm $likes=$likes1, xt='Level 2. Likes', x=$likes1, di $number=$number1, xt='Level 2. Number, dm $level=f,t, write, go back, @repeat2, ds $brand=$brand2, dm $likes=$likes2, di $number=$number2, dm $level=f,t, write, go back, @repeat3, ds $brand=$brand3, dm $likes=$likes3, di $number=$number3, dm $level=f,t, write, go back, @end, dm $level=t,f, write,
This is more complicated than it needs to be for this simple project, but you should use this method for more complicated surveys to make sure that data is only present when it is valid.
The section at the top uses “zero to finish” to clear out all the level 2 records after each repeat. This is necessary if you filter any of the repeat questions. It also ensures that answers from the last repeat are not added to the level 1 record. This section makes sure that after each repeat control returns to this section (go back). When the program has processed all repeats, it then goes to the end to write away the level 1 record.
The section for each repeat is similar and defines all the level 2 questions from the appropriate set of repeated questions. The variable $level is then set to a value of 2 (f,t) and a record written to the internal data file.
The last section, immediately before FINISH DATA then sets $level to value 1 (t,f) and writes the level 1 record.
Using the pre-processor
One of the advantages of QPSMR CL is the pre-processor which can reduce the code needed for similar repeated code. The above syntax could, and probably should, be written as follows:
[*do Repeat=1:3] go out to @repeat[Repeat], zero to finish, [*end a] go to @end, [*do Repeat=1:3] @repeat[Repeat], ds $brand=$brand[Repeat], xt='Level 2. Brand', x=$brand1, dm $likes=$likes[Repeat], xt='Level 2. Likes', x=$likes1, di $number=$number[Repeat], xt='Level 2. Number', dm $level=f,t, write, go back, [*end a] @end, dm $level=t,f, write,
IMPORTANT: This only works if the questions for the repeats have been named in a consistent manner and the response lists for repeated questions are the same.
Creating Companion Reflect files
Using QPSMR CL:
- Open the revised STP described above.
- Run the STP and check for errors. If there are errors, fix the first error listed and try again, because later errors may have been caused by the first error.
- Use [Data] [Export] [Reflect (QRFX)] to create the Companion Reflect files.
Using Companion Reflect:
- Open the QRFX.
- Delete any unwanted entries (keep IOBS and LEVEL).
- Save the QRFX.
- Run some test tables to check the conversion.
Deliver the Companion Reflect files (QRFX, ICF, IDF, ILF).