See Crunch Automation basics for more information.
Newly-uploaded datasets will have all of their variables in the order of the source they were imported from, typically a single root folder without any organization, or with whatever organization is present in their collection platform if its integration supports folders. The ORGANIZE command allows you to put groups of variables into folders, which can also be nested inside other folders. Subfolders are separated with the 'pipe' vertical bar character: |.
There are two special folders, Hidden and Secure:
- Hidden folders — Variables in a hidden folder are not visible in the Variable Sidebar, but can be accessed if referred to by another object, such as a slide or multitable.
- Secure folders — Secure folders are also hidden, and its existence and contents accessible only to dataset Editors.
If no path is provided, then one of the root folders must be indicated, and the variables will be put in the root of that tree.
ORGANIZE alias, ..., alias INTO [SECURE|HIDDEN|ROOT] ["string"];
Arguments explanation
- SECURE — Inaccessible to Viewers (due to PII). Editors can access secure variables in the Export Dataset panel.
- HIDDEN — Hidden from the Variable Sidebar but can be referenced in items an Editor creates (to move to another folder, use Dataset Properties > Edit Variables).
- ROOT — The root directory of the project tree. For example, this might be useful if you want to move a variable out of a folder.
Use case
In this example, we’ve imported the "Core Trends Study SPSS". The variables display in the Variable Sidebar as per the following:
Use the following Crunch Automation script:
# Hide the first three variables:
ORGANIZE respid, sample, comp INTO HIDDEN;
# Put the variable int_date in a new folder called "Date":
ORGANIZE int_date INTO "Date";
# Put two variables at the same time into a new folder called "Demographics":
ORGANIZE lang, density INTO "Demographics";
# And then put two other variables into a subfolder within "Demographics":
ORGANIZE cregion, state INTO "Demographics|Geography";
The hidden variables have been hidden, and the other variables have been put into the indicated folders in the project tree.
After Crunch Automation runs the script, the following appears in the Variable Sidebar: