cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Graph Builder Toolbar streamlines interactive graphing. Creates shortcuts on Report and GraphBuilder Helpers toolbars. Download and install the extension.
  • JMP will suspend normal business operations for our Rest and Recharge Day on Friday, October 2, 2026.
    Regular business hours will resume on Monday, October 5, 2026.

Discussions

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

using List as variable in an if-statement

I am trying to create a list with all column names and turning some of them into a variable.

That variable should be going into an if-statement but I am struggling with the "name unresolved" error. 

I'm guessing that JMP cannot find my previously defined variable but I do not know how to fix it even though I'm sure it should be quite simple.

dt = Current Data Table();
ColumnList = dt << Get Column Names(String);

A = ColumnList[40];

If(Contains(A, "test"),
var = :A[dt << get rows where( :column == value)];);
// I cannot seem to get it to take the column saved in A

I would also like to know how I could potentially use the text of that variable in defining a column name.

dt << New Column( "[A] at 45km/h");

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: using List as variable in an if-statement

You need to use As Column() function, and restructure the name on the new column a bit

dt = 
// Open Data Table: big class.jmp
// → Data Table( "big class" )
Open( "$SAMPLE_DATA/big class.jmp" );

ColumnList = dt << Get Column Names( String );
value = 60;
A = ColumnList[4];

If( Contains( A, "hei" ),
	var = As Column( A )[dt << get rows where( As Column( a ) == value )]
);

dt << New Column( "[" || A || "] at 45km/h");

 

Jim

View solution in original post

1 REPLY 1
txnelson
Super User

Re: using List as variable in an if-statement

You need to use As Column() function, and restructure the name on the new column a bit

dt = 
// Open Data Table: big class.jmp
// → Data Table( "big class" )
Open( "$SAMPLE_DATA/big class.jmp" );

ColumnList = dt << Get Column Names( String );
value = 60;
A = ColumnList[4];

If( Contains( A, "hei" ),
	var = As Column( A )[dt << get rows where( As Column( a ) == value )]
);

dt << New Column( "[" || A || "] at 45km/h");

 

Jim

Recommended Articles