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
Stas
Level I

Creating a column with concatenated values

Hey all, 
I'm trying to create new column which will include to rows/values. The first one is a variable and the second one is a concatenated expression of two variables.

No matter what I tried, I get an empty cell in the concatenated value. Can you please advise?

 

Example of what I tried:

stiop=10; stiPLL=20; stiPHL=30;
STIarg={char(stiop),char(stiPLL) ||"<PL<"|| char(stiPHL)};

Operations<<
New Column( "STI", "nominal", Set Values( STIarg ) );

4 REPLIES 4
txnelson
Super User

Re: Creating a column with concatenated values

I am confused.  Can you please provide an example of what you expect your new column will look like?

Jim
Stas
Level I

Re: Creating a column with concatenated values

Sorry for the confusion.
The new column suppose to look like that:

STI
10
20<PL<30
txnelson
Super User

Re: Creating a column with concatenated values

The action of JMP is to loop one row at a time through the data table when running a Formula() or Set Each Value().And by default, it will only be outputting to the current row.  There are different ways to solve your issue, but this is the way I would do it

txnelson_0-1699718550434.png

Names Default To Here( 1 );
Operations = Open( "$SAMPLE_DATA/Big Class.jmp" );

stiop = 10;
stiPLL = 20;
stiPHL = 30;
STIarg = {Char( stiop ), Char( stiPLL ) || "<PL<" || Char( stiPHL )};

Operations << New Column( "STI",
	character,
	Set each Value(
		If( Mod( Row(), 2 ) != 0,
			:STI = Eval( STIarg[1] ),
			:STI = Eval( STIarg[2] )
		)
	)
);

or if you want it to only have the 2 rows

txnelson_0-1699719368604.png

Names Default To Here( 1 );
Operations = Open( "$SAMPLE_DATA/Big Class.jmp" );

stiop = 10;
stiPLL = 20;
stiPHL = 30;
STIarg = {};
Insert into(STIarg, char(stiop));
Insert into(STIarg,Char( stiPLL ) || "<PL<" || Char( stiPHL ) );

Operations << New Column( "STI",
	character, set values(STIarg));
Jim
hogi
Level XII

Re: Creating a column with concatenated values

As an alternative, you could use EvalList to evaluate the list entries before they get used via Set Values..


Please also note that you have to specify the data type: Character.

For numeric columns, even for ones with modeling type: Nominal the value will be casted -> Numeric:

"10" will survive as 10, but the second value will get lost.

 

stiop=10; stiPLL=20; stiPHL=30;
STIarg=EvalList({char(stiop),char(stiPLL) ||"<PL<"|| char(stiPHL)});

New Column( "STI",Character, Set Values( STIarg ) );