See Crunch Automation basics for more information.
The REORDER AXES command allows you to change the order of aliases within an array variable. This command works with both categorical arrays and numeric arrays, giving you control over how aliases are displayed and organized.
A common use case for this command is in tracking studies where you want to reorder an axis list of aliases (e.g., brands or statements) based on importance, alphabetical order, or custom business logic without recreating the entire array.
REORDER AXES alias [NAME axis-name] ORDERED alias, ..., alias;How it works
The REORDER AXES command accepts a list of axis aliases in the order you want them to appear. You can perform either a full reordering or a partial reordering:
Full reordering — Specify all aliases in your desired order. The array will be reordered exactly as specified.
Partial reordering — Specify only some aliases. These will be placed at the beginning of the array in the order you specify, while any unspecified aliases will follow in their original relative order.
The NAME parameter allows modifying the order of a specific axis when a variable has multiple axes by specifying the axis name to be modified.
Examples
Suppose we have a categorical array variable named "MyArray" with the following aliases in order: "Sub1", "Sub2", "Sub3", "Sub4".
Full reordering
REORDER AXES MyArray ORDERED "Sub2", "Sub3", "Sub4", "Sub1";This will reorder the array so that "Sub2" appears first, followed by "Sub3", "Sub4", and finally "Sub1".
Partial reordering
REORDER AXES MyArray ORDERED "Sub2", "Sub3";This will place "Sub2" and "Sub3" at the top of the array, followed by "Sub1" and "Sub4" in their original relative order. The resulting order will be: "Sub2", "Sub3", "Sub1", "Sub4".
Requirements
The aliases must exist in the array — All aliases specified in the ORDERED clause must be valid alias of the target array axis. If you reference an alias that does not exist in the array axis, the command will fail with an error.
Aliases must be unique — You cannot specify the same alias multiple times in the ORDERED clause.
Notes
- Partial reordering is useful when you only need to prioritize certain axes without manually specifying the complete order.
- The command affects the display order of axes but does not change the underlying data or axis definitions.
- This command works on both derived arrays and arrays defined in your original data.