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
sophiaw
Level III

Creating Columns

Okay, this probably sounds like a really easy question, but I'm having a hard time with it.

 

So I have this data that is formatted like: (number)|(name)|(number)|(name)|(number).... etc. Well I have a loop that looks at the string, parses the information by the delimiter ('|') and then takes every other entry in that new list (all the "names") and puts only those in the new list. That new list is then used to create a whole bunch of columns. What I have discovered is that the numerical values that I then use from that string and place in each column is technically a character, so when I try to use a formula on the column, it just dots everything out. What I have to do is make a new column and use the formula on that column. My question is: I already have a list of all the column names I want, is there a way to create new columns with the same names and just replace the initial columns I make with the columns that can handle the format?

 

That question might be really weird, here is some of my script that handles the parsing/column making:

 

List = {};

// Iterate through the first rows of :Test_Result to get the pin names

one_test_result_list = words(column(dt2,"Test_Result")[1], "|");

For(j = 1, j <= nitems(one_test_result_list)/2, j++,

      Assign(List, one_test_result_list[j*2]);

);

 

// Make new columns of the pin list

For(g = 1, g <= nitems(List), g++,

     dt2 << New Column(List, Numeric, Continuous, Format("Best",12));

);

 

// Iterate through the rows of :Test_Result (where the string is stored)

For (i = 1, i <= nrows(dt2), i++,

     one_test_result_list = words(column(dt2,"Test_Result"), "|");

 

     For(k = 1, k < nitems(one_test_result_list)/2, k++,

     // Store all the newly parsed results into new values

     Column(dt2, List) = num(one_test_result_list[(k*2)+1]);

     );

);

 

 

This works perfectly, I just found out about the whole making new columns thing... I want them to have the column names I already gave them, I just want to be able to put the format on them without every value turning into a dot. (I did test this on a new column and the values actually change correctly....)

 

Thank you so much!

1 ACCEPTED SOLUTION

Accepted Solutions
ian_jmp
Level X

Re: Creating Columns

Not sure I fully understand your issue, but "the numerical values that I then use from that string and place in each column is technically a character, so when I try to use a formula on the column, it just dots everything out" suggests a few things . . .

The data type of a JMP column can be defined as 'Numeric' or 'Character' to hold data of the requisite type, and (via the 'Column Info...' dialog or by sending the JSL message 'myCol << DataType("Numeric") or myCol << DataType("Character")') you should set this to be what you want. When you populate the column with values, you can convert from numeric to character values (from character to numeric values) using 'Char()' (using 'Num()'). If you use 'Num()' on a text value that JMP cannot interpret as a number, it will assign a missing value (a '.').

View solution in original post

2 REPLIES 2
ian_jmp
Level X

Re: Creating Columns

Not sure I fully understand your issue, but "the numerical values that I then use from that string and place in each column is technically a character, so when I try to use a formula on the column, it just dots everything out" suggests a few things . . .

The data type of a JMP column can be defined as 'Numeric' or 'Character' to hold data of the requisite type, and (via the 'Column Info...' dialog or by sending the JSL message 'myCol << DataType("Numeric") or myCol << DataType("Character")') you should set this to be what you want. When you populate the column with values, you can convert from numeric to character values (from character to numeric values) using 'Char()' (using 'Num()'). If you use 'Num()' on a text value that JMP cannot interpret as a number, it will assign a missing value (a '.').

sophiaw
Level III

Re: Creating Columns

Sorry, I was wording that weirdly. In my string, I ignore the first number (because it's useless) and then it is a name followed by the value for that name. I create a new list take just collects all the names, and then I use that list to populate all the new column names. I do set the columns as numeric values, and I even populate the columns with their corresponding numeric value as a num. As seen in this code I attached (the bolded lines in particular):

 

// Make new columns of the pin list

For(g = 1, g <= nitems(List), g++,

    dt2 << New Column(List, Numeric, Continuous, Format("Best",12));

);

For (i = 1, i <= nrows(dt2), i++,

    one_test_result_list = words(column(dt2,"Test_Result"), "|");

 

    For(k = 1, k < nitems(one_test_result_list)/2, k++,

    // Store all the newly parsed results into new values

    Column(dt2, List) = num(one_test_result_list[(k*2)+1]);

    );

);

 

 

Even though I designate the value as a number and the column to hold a numeric value, whenever I perform any sort of operation on that column (ie. making the column all absolute values) it changes the values that are in that column turn into dots. But if I make a new column, and take the values in, say, the first column I created, and set a formula for that column, it behaves properly and shows the operation. It seems that I need to make twice as many columns as I really need to initially store the value, and then another column to use a formula on. I can't just use a formula on the first column I create. The thing is, I want to keep the column names I assigned initially. I don't know why JMP won't let me perform an operation on the new columns.