Col Number
Col Number using New Column
Summary: Prepares data by creating new columns with numerical values from categorical variables, utilizing the Col Number formula.
Code:
dt = Open("data_table.jmp");
dt:name[[1, 3, 8]] = "";
dt:height[[3, 7, 11]] = .;
New Column( "n1", Formula( Col Number( :height ) ) );
New Column( "n2", Formula( Col Number( :name ) ) );
New Column( "n3", Formula( Col Number( :height, :sex ) ) );
New Column( "n4", Formula( Col Number( :name, :sex ) ) );
Code Explanation:
- Open data table.
- Clear values in name column.
- Set height values to missing.
- Create new column n1.
- Apply Col Number formula to height.
- Create new column n2.
- Apply Col Number formula to name.
- Create new column n3.
- Apply Col Number formula to height and sex.
- Create new column n4.
- Apply Col Number formula to name and sex.