- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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:
StdURM1BLFI | StdURM1BLMI | |
. | . | |
-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.:
StdURM1BLFI | StdURM1BLMI | Zscore |
. | . | . |
-0.0316815 | . | -0.0316815 |
. | -0.33056098 | -0.33056098 |
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to joining two columns with JSL
The sum function works! Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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