cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
ENTHU
Level IV

Create a column based on values on other columns

I am trying to write a script whose values depend on the value of another column.I need to create a new column i.e second column below.Need to assign vales as follows

Sun = 1,Mon = 2 and so on.

(4) => 2 , (6) => 4,5 => 1, 7 => 3

Eg : Sun(5) is 11.How can I script this?

Sat (4)72
Sun (5)11
Sun (4)12
Mon (5)21
Mon (4)22
Tue (5)31
Tue (4)32
Wed (5)41
Fri (7)63
Wed (6)44
Thu (7)53
Thu (6)54
Fri (6)64
Sat (7)73
3 REPLIES 3
txnelson
Super User

Re: Create a column based on values on other columns

I would just use lists to convert the values.....here is a sample format

parenList = {"", "", "", "2", "1", "4", "3"};
daysList = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
result = Char( Contains( daysList, Word( 1, :Column 1, " " ) ) ) || parenList[
Num( Word( 2, :Column 1, "()" ) )];
Jim
ENTHU
Level IV

Re: Create a column based on values on other columns

I tried this approach but see the following error -

invalid subscript (must be number or list of numbers) in access or evaluation of 'Subscript'.

My column is character changed it to numeric but doesnt seem to work.

txnelson
Super User

Re: Create a column based on values on other columns

I have attached a data table with your sample data, and my formula.  It runs without error.  You should be able to determine what the differences are in comparison with this data table to find out where the error is coming from

Jim