cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Use World Cup data to build models, explore spatial relationships, and create informative visualizations in JMP. Register. July 17, 2 pm US Eastern Time.
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

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

How to joining two columns with JSL

Hi I am new to JSL, and I got stuck in a seemlily easy task.

Say I have two columns A and B, and have some missing values.

I'd like to create a new column to be the join of column A and B.

As shown in example below. 

 

Thanks!

 

Snap278.bmp

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How to joining two columns with JSL

Here is a couple of simple examples

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/big class.jmp" );

dt << New Column( "New Column", character, formula( name || sex ) );

// or 
dt << New Column( "Second New Column", character );
For( i = 1, i <= N Rows( dt ), i++,
	dt:Second New Column[i] = dt:name[i] || dt:sex[i]
)are 
Jim

View solution in original post

5 REPLIES 5
txnelson
Super User

Re: How to joining two columns with JSL

Here is a couple of simple examples

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/big class.jmp" );

dt << New Column( "New Column", character, formula( name || sex ) );

// or 
dt << New Column( "Second New Column", character );
For( i = 1, i <= N Rows( dt ), i++,
	dt:Second New Column[i] = dt:name[i] || dt:sex[i]
)are 
Jim
meperry
Level I

Re: How to joining two columns with JSL

I am having the same issue, but the code provided here does not work.  I am dealing with continuous data, perhaps that is the problem? Or is it that my variable names are longer than SAS allows, so using them in JSL creates an error?

 

My data subset looks like such:

 

StdURM1BLFIStdURM1BLMI 
.. 
-0.0316815. 
.-0.33056098 

 and I would like the third column to contain the data from the other two (or keep a missing data value as necessary), e.g.:

 

StdURM1BLFIStdURM1BLMIZscore
...
-0.0316815.-0.0316815
.-0.33056098-0.33056098

 

Thank you!

ian_jmp
Level X

Re: How to joining two columns with JSL

So long as only one of the two columns has a non missing value, you could try 'Sum()'. Look at the formula in the table below:

New Table( "Both",
	Add Rows( 4 ),
	New Column( "a",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [., 1, ., 3] )
	),
	New Column( "b",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [., ., 2, 4] )
	),
	New Column( "c",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( Sum( :a, :b ) )
	)
) e

 

meperry
Level I

Re: How to joining two columns with JSL

The sum function works!  Thank you!

hogi
Level XIII

Re: How to joining two columns with JSL

It's amazing how easy such things are in JMP - even by hand (no problem if the patterns are irregular and the table has 5 mio entries).

Just watch this video by @brady_brady : 
Columns Menu  (~ 2min)

 

Alternative approach: 

use the Merge Columns add-in  by @john_madden 

Recommended Articles