cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
bernie426
Level II

How to write a command on Formula-Character

I will like to know how to write a workable command using Formula-Character functionality.

For example, I have a column of character data that have data like leveled from Class 1.0 to Class 9.0.

I would like convert this information to another column that only show 1.0 to 9.0, how can I use the formula character function to write a command for this?

The other request I like to know is how can I change a column of character data to another statement in a new column.

For example, I have a character column of data showing sweet, tasty, sour,...and I would like to change it to be sweet-->Bin1, tasty-->Bin2, sour-->Bin3. How can I use the formula character to convert the sweet-->Bin1 in a new column.

Thanks,

10 REPLIES 10
julian
Community Manager Community Manager

Re: How to write a command on Formula-Character

Hi Bernie,

I'm sorry this isn't working for you! I think I may have chosen an ambiguous column name which I think might be the source of the confusion. In the attached dataset I have a column named "OriginalColumn"  and the script below references that column in the Word() function. The word function doesn't take any arguments for which words it is looking for, only which word number, and the column to look in. It was my mistake to use a column name of "Class" when that was what you were looking to remove!  Let me know if the script below works for the attached table. If it does, you should be able to change it around to work for any table you want by changing " :OriginalColumn " to match whatever the name is of the column in your table.

julian

//Make a new column

Current Data Table() << New Column("ClassNumberOnly", Character);

//stop table update until all changes are made, good for large tables

Current Data Table() << Begin Data Update;

//Apply changes to each row

For Each Row(

  :ClassNumberOnly = Word( 2, :OriginalColumn )

);

// End "Data Update"

Current Data Table() << End Data Update;