There are several specialized tasks that you can perform on a dictionary using the dictionary macros functionality. To access the options, either right-click on a dictionary in the tree and select Dictionary Macros or, with the dictionary editor active, select Dictionary Macros from the Edit menu. A dialog box will appear with the following options:
You can Copy All the names and labels to the clipboard for all attributes in your dictionary (levels, records, items, and value sets). If your dictionary has multiple languages, the All Languages option allows you to copy all of the labels, instead of just the primary label, to the clipboard. The Item Lengths option allows you to copy, in addition to the names and labels, the length of each item to the clipboard.
This can be useful if you want to edit the names, labels, and lengths in a different software tool, such as Microsoft Excel. The information is copied in a tab-delimited format.
If you edit the data in an outside program and want to bring the changes back to CSPro, you can use the Paste All functionality. CSPro will check that what is in the clipboard matches the contents of the dictionary, so you cannot add or delete items outside of CSPro.
You may find it useful to setup your dictionary parameters in CSPro and then have a subject matter specialist or clerk enter the labels in another software, particularly if working in multiple languages.
You can Copy All the names and labels to the clipboard for all value sets in your dictionary. As with dictionary names and labels, you can use this feature to edit the value sets in a different software tool. If your dictionary has multiple languages, the All Languages option allows you to copy all of the labels, instead of just the primary label, to the clipboard. If you select Value Set Images, the file names of value set images will also be copied.
After modifying the value set labels in an outside program, you can use the Paste functionality to bring the changes back to CSPro. You do not need to paste all value sets, so you can make changes to only the value sets that you want to modify. You can add and remove value set labels in the outside program, but you cannot change value set names.
If you want to remove all the value sets from your program, which can be useful if testing a data entry application that someone else designed (and for which you do not know the proper values), you can use the Delete All functionality. The change is permanent, however, so you may want to make a copy of your dictionary prior to removing all value sets.
This macro allows you to bulk add items to a record. This can be useful if you want to add many items to your dictionary, whose names and labels you will modify in a different software tool. Specify the Number of Items to add, and then select to which Record you want to add the items. The items will come with names such as RECORD_NAME_ITEM001, RECORD_NAME_ITEM002, etc.
In a dictionary with many records, it may be useful to modify all records to make all required (Set All to Required) or to make none required (Set All to Not Required).
Sometimes, particularly when testing a data entry or batch edit application, you may want to create a data file with some Number of Cases in it. If you do not have any preexisting data for your dictionary, this is a way to easily generate data without having to enter it manually. The output file will consist of cases with data based on your dictionary's specifications. For items with value sets, only valid values will be output.
If you want some number of blank values in your output file, you can modify the Percent Not Applicable. If you want some items to have values that are not in their value sets, than you can modify the Percent Invalid. When testing batch edit applications, this can be useful as a way to detect if your edits properly handle blank and out-of-range values.
This macro provides an easy way to create a sample from an existing data file. For example, it is a common task to create a 1%, 5%, or 10% sample census data file, particularly when testing batch edit applications. Based on the provided Percent, you can create a Random or Sequential sample data file.
Suppose your file has 100 cases and you want to create a 10% sample. Creating a random sample means that all 100 cases have a 10% change of being selected for the sample. Based on randomness, that means that generally your sample file will have 10 output cases, but it could have fewer or more. You might also get some clumping of cases. On the other hand, a sequential sample means that the output file will consist of the 1st, 11th, 21st, ... cases. The output file will always have 10 cases. By modifying the Start Position, you can control which case is output first. For example, if that value was 3, then your output file would consist of the 3rd, 13th, 23rd, ... cases.
There are three options in this area:
- Compact Data: When working with Text data sources as external dictionaries to a program, you can end up with a lot of deleted records. Deleted records appear in the file with a tilde (~) at the beginning of the line. This option will remove all deleted records from a file, reducing its size.
- Sort Data in ID Order: This will run the Sort Data tool to automatically sort a data file in ID order. Particularly after concatenating multiple data files, you may want to sort the data in some order, generally based on geographic ID items.
- Create Notes Dictionary: This will create a new dictionary, based on your current one, that can be used to read the .csnot notes file generated by a data entry application. If you want to export your data entry notes, you can use this macro and then open the newly created dictionary in the Export Data tool.