cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP will suspend normal business operations for our Winter Holiday beginning on Wednesday, Dec. 24, 2025, at 5:00 p.m. ET (2:00 p.m. ET for JMP Accounts Receivable).
    Regular business hours will resume at 9:00 a.m. EST on Friday, Jan. 2, 2026.
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.

Discussions

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

loop and concatenate

I need to create a new column which is a concatenate of a set of column 

I just hard code the column name as below ...

 

new column("Code","character",
formula(:deliver || :func_groupa || :func_groupb_h || :func_groupb_l || :micro firmware load
|| :micro module build || :micro setup)
);

 

however, I want to create a script that can get the number of column from that input file and start concatenate the value inside (same as above) 

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: loop and concatenate

Here is one way to do what you want

names default to here( 1 );
// Open a sample data table
dt = Open( "$SAMPLE_DATA/big class.jmp" );

// Get all of the character columns for concatenating
colNames = dt << get column names(character,string);

// Build a command string that generates the JSL to create the column
theExpr = "dt << new column( \!"concat\!", character, formula( concat(:" || colNames[1];

For( i = 2, i <= N Items( colNames ), i++,
	theExpr = theExpr || ",:" || colNames[i]
);

theExpr = theExpr || ")));";

// Run the command string
Eval( Parse( theExpr ) );
Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: loop and concatenate

Here is one way to do what you want

names default to here( 1 );
// Open a sample data table
dt = Open( "$SAMPLE_DATA/big class.jmp" );

// Get all of the character columns for concatenating
colNames = dt << get column names(character,string);

// Build a command string that generates the JSL to create the column
theExpr = "dt << new column( \!"concat\!", character, formula( concat(:" || colNames[1];

For( i = 2, i <= N Items( colNames ), i++,
	theExpr = theExpr || ",:" || colNames[i]
);

theExpr = theExpr || ")));";

// Run the command string
Eval( Parse( theExpr ) );
Jim
yanee
Level III

Re: loop and concatenate

Thank you so much ..

Recommended Articles