The Mutate block enables you to create a new dataset variable based on existing variables in the dataset.
The following demonstrates how to use an expression in the Mutate block to create a new variable in the loan_data dataset (containing observations each of which describes a completed loan and the person who took the loan out). The new variable is_human? initially contains the default value Yes:
- Import the loan_data.csv dataset onto a Workflow canvas using the Text File Import block.
- Expand the Data Preparation group in the Workflow palette, then click and drag a Mutate block onto the Workflow canvas.
- Click the Output port of the loan_data dataset block and drag a connection towards the Input port of the Mutate block.
- Double-click the Mutate block to display the Configure Mutate dialog box.
- In the Configure Mutate dialog box:
- Click the Add Variable button.
- In the Variable Definition pane:
- In the Name dialog box, type Is_Human?.
- In the SQL Expression text box, type 'Yes'.
- Click OK to save the configuration and close the Configure Mutate dialog box.
A green execution status is displayed in the Output port of the Mutate block and the new Working Dataset. The Mutate block output dataset contains the input loan_data with the new Is_Human? variable.