Pivoting transposes data from a vertical to a horizontal format.
Important: Pivot and Unpivot transformations respect user privileges and configured Data Blinding rules. If the user or execution account has the Blinded Data View privilege, unblinded values may appear in previewed results and may be included in reshaped output columns or rows. Verify that access privileges align with the study’s blinding strategy before creating or executing transformations that include sensitive data.
For example, SDTM lab data is often reported so that each lab test is a separate record per visit, per subject, per test. This structure can make it difficult to compare results from different tests or against a baseline.
Using Pivot, a table can be created that includes multiple lab tests in each row.
Original
| STUDYID | USUBJID | LBDTC | LBTESTCD | LBTEST | LBRORES | LBORESSU |
|---|---|---|---|---|---|---|
| 1 | 1 | 2015-06-01 | HCT | 45.2 | % | |
| 1 | HGB | 15.4 | G/DL |
Pivot
| STUDYID | USUBJID | LBDTC | HCT | HCT_UNIT | HGB | HGB_UNIT |
|---|---|---|---|---|---|---|
| 1 | 1 | 2015-06-01 | 45.2 | % | 15.4 | G/DL |
Create a Pivoted Table
- Select the domain in the Domain Editor window, then click the Variable drop-down and select Pivot.
- A pivot box is added to the selected domain, and a warning appears in the preview area to specify settings. The Pivot options also display in the Domain Properties subpanel.
- A pivot box is added to the selected domain, and a warning appears in the preview area to specify settings. The Pivot options also display in the Domain Properties subpanel.
- Double-click the Pivot box, or click the ellipsis next to a Pivot field in the Domain Properties subpanel. The Edit Pivot window opens.
- Drag the variables or columns to include in the results to the Key Columns pane.
- These fields repeat the same values for each pivoted key.
- Drag the column containing the data to pivot to the Pivot Key field. Values from this column appear in the Pivoted Values list.
Example: When pivoting lab data, the lab test ID can serve as the pivot key. The names of the lab tests appear as values, allowing selection of which labs to include in the results.
Note: Variables in the Key Columns and Pivoted Columns fields can be reordered by dragging them into the desired position.
- Select the items to pivot from the Pivoted Values list.
- Drag the column or variable to display for each selected pivoted value to the Pivoted Columns field.
- Multiple fields can be selected using Ctrl+Click or Shift+Click.
- Example: If the lab test ID is the pivot key and the labs HCT, HGB, and CREAT are selected, the Lab Result and Lab Result Unit fields might be selected as pivoted columns.
- Edit the Column Prefix and Suffix as needed.
- When a pivoted column is selected, the variable ID can be displayed as a prefix or suffix, depending on configuration.
- Example: Removing the suffix from the result column displays only the lab name.
- Click Save. The domain mapping window reopens, and the pivot results appear in the preview area.
Note: When pivoting blinded data, the resulting columns inherit the displayed values from the source data based on the current user’s privileges and Data Blinding configuration. Review pivoted results carefully to confirm sensitive values remain protected as expected.
Use Unpivot to Map Data
Depending on the data source, the format of the data may not match reporting requirements.
In many cases, such as vital signs or lab data, it is preferable to transpose data so that each row represents a single test result, rather than multiple test results in one row. This structure simplifies filtering for specific labs or tests.
- Select the domain in the Domain Editor window, then click the Variable drop-down and select Unpivot.
- An Unpivot box is added to the selected domain, and a warning appears in the preview area to specify settings.
- The Unpivot options also display in the Domain Properties subpanel.
- Double-click the Unpivot box or click the ellipsis next to the Unpivot fields in the Domain Properties subpanel. The Edit Unpivot window opens.
- Drag the columns to include in the results to the Key Columns pane.
- These fields repeat the same data for each unpivoted variable value.
- Multiple fields can be selected using Ctrl+Click or Shift+Click, and reordered by dragging.
- Drag the columns to unpivot into the Unpivot Variables field.
- Multiple fields can be selected using Ctrl+Click or Shift+Click, and reordered by dragging.
- The field names become the initial values for the unpivoted column, and their values become the first value series.
- Click Add Value Series and drag additional fields to create more value sets for the selected variable.
- Click Save. The domain mapping window reopens, and the unpivoted results display in the Preview area.
Note: When unpivoting blinded data, the resulting rows reflect the displayed values from the source data based on the current user’s privileges and Data Blinding configuration. Review unpivoted results to ensure sensitive values remain protected as expected.
Variable names can be edited by clicking the ellipsis (…) in the Variables field or by double-clicking the column header in the preview area.
Note: Auto-complete remains available for recognized standard domains.