cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
Liranlev
Level II

Concatenation highlights of columns

Hello there,

I have a table with some columns, for example, "HIGH" and "SMART," and there are three optional values: "0," "1," and "None."

I want to create a new column that describes each row.

For example, if the first row has a "1" in the "HIGH" and "SMART" columns, the new column should contain "HIGH, SMART."

 

How can I achieve this using column formulas?

Thank you.

2 REPLIES 2
jthi
Super User

Re: Concatenation highlights of columns

If you have a table like this

jthi_3-1718700703476.png

you can use formula

vals = {};
If(:H == "1", Insert Into(vals,"H"));
If(:S == "1", Insert Into(vals,"S"));

Concat Items(vals, ", ");

jthi_4-1718700721287.png

 

There are also many other methods of achieving this

-Jarmo
hogi
Level XII

Re: Concatenation highlights of columns

What you describe is almost the application case of Combine Columns with the setting Selected Columns are Indicator Columns.

 

But is will complain about the Nones.

To fix the issue, get rid of the None values -  either via Recode or by just converting the columns to data type numeric:

 

dt = New Table( "test",
	Add Rows( 5 ),
	New Column( "H",
		Character,
		Set Values( {"None", "1", "0", "1", "1"} )
	),
	New Column( "S",
		Character,
		Set Values( {"1", "0", "1", "None", "1"} )
	)
);

:H << Set Data Type( Numeric );
:S << Set Data Type( Numeric );

dt << Combine Columns(
	columns( :H, :S ),
	Column Name( "summary" ),
	Delimiter( "," ),
	Selected Columns are Indicator Columns( 1 )
);