Subscribe Bookmark RSS Feed

JMP Column Names - Retrieving and Renaming

whom

Community Trekker

Joined:

Jun 23, 2011

I am trying to read in the names of the column names in my JMP file, in order to rename specific ones with a prefix. I wrote a loop and it appears to retrieve all of the column names correctly, but when I use an IF statement to check the values, the IF statement is failing, even though it appears that there should be a match.

Below is the same code... the variable a is a flag.

The first column in the JMP table was changed the "ABC". After retrieving the column name, I check to see if it's equal to ABC. If so, then I change the variable a to 1.

In the show statements, the value of variable a never changes. Any ideas?

a = 0;
For (i = 1, i <= NCol(dt1), i++,
ColName = column name(i);
show (a, i, ColName);
if (ColName == "ABC", a = 1);
show (a, i, ColName);
show ("============");
); /* END OF FOR */
/*:


RUN RESULTS:
a:0
i:1
ColName:ABC
a:0
i:1
ColName::ABC
"============"
a:0
i:2
ColName:Country
a:0
i:2
ColName::Country
"============"
2 REPLIES
whom

Community Trekker

Joined:

Jun 23, 2011

ack.. a less than character in the script caused the rest of the message to truncate...
Below, "less than or =" should be replaced with the mathematical symbol for less than.

a = 0;
For (i = 1, i less than or = NCol(dt1), i++,
ColName = column name(i);
show (a, i, ColName);
if (ColName == "ABC", a = 1);
show (a, i, ColName);
show ("============");
); /* END OF FOR */
/*:

a:0
i:1
ColName:ABC
a:0
i:1
ColName::ABC
"============"
a:0
i:2
ColName:Country
a:0
i:2
ColName::Country
"============"
mpb

Super User

Joined:

Jun 23, 2011

Change the third line to:
ColName = char(column name(i));

Also, search the pdf scripting docs for: "column name" where this is discussed.