cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Sign-in to the JMP Community will be unavailable intermittently Dec. 6-7 due to a system update. Thank you for your understanding!
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.
  • JMP 19 is here! Learn more about the new features.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
wyatt_dunn
Level I

Using loop variable as column input

Hello,

 

I am wondering if it possible to use my for loop variable, i, as an input for a new column, depending on the value of another column.  Here is what I am thinking, but cannot get to work.

dt << New Column("Site", Numeric, Formula(
   For(i = 1, i <= 8, i++,
      If(Contains(:Column1, i), i);
   )
));

 

2 REPLIES 2
txnelson
Super User

Re: Using loop variable as column input

You certainly can.  The only issue you have is that the Contains() function is a character handling function, and the arguments passed to it must be character(string) values.  I am assuming :Column1 is a character column so all you need to do is to convert the index variable "i" from a numeric to character

dt << New Column("Site", Numeric, Formula(
   For(i = 1, i <= 8, i++,
      If(Contains(:Column1, char(i) ), i);
   )
));
Jim
pauldeen
Level VI

Re: Using loop variable as column input

What is it your a trying to do, do you have some example data?

Do you want to copy the value of Column1 to another column?

Do you want to take the value from another column based on the numeric reference in column1?

Recommended Articles