Scripting Guide > Data Tables > Columns > Recode Columns
Publication date: 04/12/2021

Recode Columns

Use Recode Column 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, 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" );
col = New Column( :Gender );
dt << Recode Column(
		_rcNow == 1, 0,
	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

dt = Open( "$SAMPLE_DATA/Big" );
dt << Recode Column(
		_rcNow >= 17, "Older",
		_rcNow >= 15, "Middle",
	Target Column( :age)
Want more information? Have questions? Get answers in the JMP User Community (