JMP Users I have a simple question I would like to create a new column and populate it with data based upon information in and existing column. For examples, say I have a column of "Animals" as so:
I WOLD LIKE TO WRITE JSL SCRIPT TO ADD A "CATEGORY" COLUMN AND TO POPULATE THE CATEGORY COLUMN WITH DATAT. WITH THE RESULTS BEING:
SO IF THE ANIMAL IS A MAMMAL I WANT THE CATEGORY COLUMN TO POPULATE "MAMMAL", IF THE ANIMAL IS A REPTILE I WANT THE CATEGORY COLUMN TO POPULATE "REPTILE", ETC.
The easiest way to do this would be to create a lookup data table that has the master set of animals matched with the category; Then all that has to be done is to Update the data table with the lookup table, specifying to keep all rows in the original table, but only the matching rows from the lookup table.
Names Default To Here( 1 );
dt = Data Table( "Data" );
dtud = Data Table( "Lookup" );
Data Table( "Data" ) << Update(
With( Data Table( "Lookup" ) ),
Match Columns( :ANIMAL = :ANIMAL )
To do this by hand (without a script) you can use Cols->Utilities->Recode on your original column.
When you click the Done button you'll have the option of creating a Formula Column which will create a new column with a formula that will assign values based on the animal.
Here's a video showing Recode.