Use the Recode Column message to change all of the values in a column at once. Specify the original column, or reference column, a list of transformations, and a target column. The function applies the transformations to the reference column, updating the target column. If the Update Properties argument is turned on, the following column properties are updated when a column is recoded: Value Labels, Value Scores, Value Order, Value Colors, Supercategories, Coding, and Missing Value Codes.
obj << Recode Column(<column reference>, {<transform>, ...}, <Update Properties(0|1)>, Target Column(<column reference> | <column name>))
For example, in Consumer Preferences.jmp, change the coding of the Gender column to 0|1 instead of 1|2, but keep the value labels the same.
dt = Open( "$SAMPLE_DATA/Consumer Preferences.jmp" );
col = New Column( :Gender );
dt << Recode Column(
:Gender,
{if(
_rcNow == 1, 0,
1,
)},
Update Properties( 1 ),
Target Column( col )
);
You can also make the transformations to the original column. Recode the age column to age groups in Big Class.jmp.
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Recode Column(
:age,
{if(
_rcNow >= 17, "Older",
_rcNow >= 15, "Middle",
"Younger"
)},
Target Column( :age)
);