Why MRDCL for crosstabs / tabulations?
MRDCL is one of a small number of software produc…Read more
One of the worst practices of any type of programming is where code is copied and pasted because it is identical or similar. Copying and pasting may seem like an easy route, but it is both easy to make mistakes and it means that if changes are needed the change will need to be repeated. In MRDCL, there is no need to do this as there are tools to manage minor run differences and tools to execute multiple runs of data.
What this blog article will show you
Never duplicate .stp files
If you have, for example, three MRDCL .stp run files that are almost the same, you have probably not used MRDCL in the best way. It would be more effective to have one run file which contains the variations between each of your three MRDCL run files.
MRDCL tools for dealing with questionnaire differences
It is quite common to have a project with minor questionnaire variations or runs that have different sets of tables required monthly, quarterly and annually, for example. The example below shows how to handle different age groups that have been collected in 4 different countries. The differences could equally be table selections, data recoding or any of the other techniques used in MRDCL.
In the control stage of your MRDCL script, you will need to set a prompt for the run you wish to execute. Code such as this will prompt the user to enter a country code:
When this run is compiled, the user will be prompted to enter a value. You simply enter the code you want and the run will proceed. You can have as many of these prompts as you wish.
To select the right code, you can use *SKIP commands. For example:
[*sk 99 on country.ne.1]
[*sk 99 on country.ne.2]
[*sk 99 on country.ne.3]
[*sk 99 on country.ne.4]
*ASK commands work in the same way as Pre Processor code responses, but offer the additional benefit of producing a menu with a list of options. Text based choices are particularly easier to use with runs that are executed infrequently. You would use the same code as above having determined the value of country and which age groupings are processed.
There are two steps. You need a data statement and a *ASK command. You can have as many *ASK commands as you wish. The data list should contain the options and the *ASK command provides the prompt. The code should appear as:
When compiling, this would appear as a menu where a selection can be made.
If Singapore is selected, it would set country to a value of 2, which would mean that the code generated (if the same code was used) would have 2 codes with age groups of 16-45 and 45+.
Preparing batch runs to execute multiple runs
Having prepared one run with all the differences, you may want to run a number of runs without making the selections manually and having to wait while each run executes. You can use this technique to run several runs or several runs where Pre Processor Response Codes need to automatically entered.
Let’s say you want to run a set of tables for each country setting the value of country to 1, 2, 3 and 4. You could generate a file that contains all of the commands and run control parameters you need. The file would contain four lines. For example:
start /wait “Title" "C:\Program Files (x86)\MRDC Software\MRDCL 2016.1a\mrdcl.exe" "c:\ projects\run.stp" ppcountry=1 o="UK" W8
start /wait “Title" "C:\Program Files (x86)\MRDC Software\MRDCL 2016.1a\mrdcl.exe" "c:\ projects\run.stp" ppcountry=2 o="Singapore" W8
start /wait “Title" "C:\Program Files (x86)\MRDC Software\MRDCL 2016.1a\mrdcl.exe" "c:\ projects\run.stp" ppcountry=3 o="USA" W8
start /wait “Title" "C:\Program Files (x86)\MRDC Software\MRDCL 2016.1a\mrdcl.exe" "c:\ projects\run.stp" ppcountry=4 o="Japan" W8
You will note that all texts appear in double quotes.
Naming and running the batch file
This file should take the file extension .bat – for example, mycountryruns.bat. To execute it, you can just click on it in the Windows Explorer.
Explanation of each part of the batch file’s contents
To explain each part of the script:
start /wait “Title" – This is a Microsoft Windows command with a run title that you can choose
"C:\Program Files (x86)\MRDC Software\MRDCL 2016.1a\mrdcl.exe" – This is the path to your MRDCL installation
"c:\ projects\run.stp" – This is the path and file you wish to run
ppcountry=1 – This is the setting for this run (you can put anything that would appear in the control stage here, including commands such as CEP.
o="Singapore" – This is a run control parameter which tells MRDCL to output tables to Singapore tables.txt and Singapore tables.csv. You need this otherwise each run of tables would be written to the same file and overwrite each time.
W8 – This is mandatory Microsoft Windows command
Errors in your batch file or MRDCL scripts
Any errors in your batch file will cause that line of the file to be ignored. Any runs that contain MRDCL errors, such as compilation errors, will proceed normally. Therefore, checking that all your output files have the right time stamp is important in case a run failed to execute.
If you have any questions about using these techniques, please feel free to email me.