cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMPĀ® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Neo
Neo
Level VI

How to supply argument to delimiter in combine columns ()?

The following does not work

Names Default To Here (1);
// Combine columns
dm = ".0";
Data Table( "myTable" ) << Combine Columns(
	columns( :Col1, :Col2 ),
	Column Name( "ID" ),
	Delimiter(dm)
  //Delimiter ("dm")
);

But writing the argument to Delimiter directly as 

Delimiter(".0")

works. How to supply argument to the delimiter from outside?

When it's too good to be true, it's neither
1 ACCEPTED SOLUTION

Accepted Solutions
Jeff_Perkinson
Community Manager Community Manager

Re: How to supply argument to delimiter in combine columns ()?

The Combine Columns message is doing the same as Cols > Utilities > Combine Columns.

Combine Columns doesn't support any conditionalizing.

 

Instead, I'd create a new column with a formula to concatenate your other columns as you desire.

 

Here's what the formula would look like in the Formula Editor.

2023-06-12_13-54-45.269.png

 

And here's the JSL to create it.

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
// Combine columns
dm1 = ":";
dm2 = "-";
Eval(
	Substitute(
			Expr(
				dt << New Column( "ID",
					Character,
					"Nominal",
					Formula( :name || If( :age <= 13, d1, d2 ) || Char( :age ) ), 

				)
			),
		Expr( d1 ), dm1,
		Expr( d2 ), dm2
	)
);

 

-Jeff

View solution in original post

3 REPLIES 3
Jeff_Perkinson
Community Manager Community Manager

Re: How to supply argument to delimiter in combine columns ()?

This happens because JMP doesn't evaluate arguments to arguments in messages.

 

You can use Substitute to substitute in the value of dm.

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
// Combine columns
dm = ":";
Eval(
	Substitute(
			Expr(
				dt << Combine Columns(
					columns( :name, :age ),
					Column Name( "ID" ),
					Delimiter( d )
				)
			),
		Expr( d ), dm
	)
);
-Jeff
Neo
Neo
Level VI

Re: How to supply argument to delimiter in combine columns ()?

@Jeff_Perkinson Thanks. In this case, how to script, if I have a condition on the delimiter -  e.g.  delimiter = ".0" if : age <13 and delimiter = ".1", otherwise.

When it's too good to be true, it's neither
Jeff_Perkinson
Community Manager Community Manager

Re: How to supply argument to delimiter in combine columns ()?

The Combine Columns message is doing the same as Cols > Utilities > Combine Columns.

Combine Columns doesn't support any conditionalizing.

 

Instead, I'd create a new column with a formula to concatenate your other columns as you desire.

 

Here's what the formula would look like in the Formula Editor.

2023-06-12_13-54-45.269.png

 

And here's the JSL to create it.

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
// Combine columns
dm1 = ":";
dm2 = "-";
Eval(
	Substitute(
			Expr(
				dt << New Column( "ID",
					Character,
					"Nominal",
					Formula( :name || If( :age <= 13, d1, d2 ) || Char( :age ) ), 

				)
			),
		Expr( d1 ), dm1,
		Expr( d2 ), dm2
	)
);

 

-Jeff