Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- How to joining two columns with JSL

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jan 31, 2017 4:51 PM
(1499 views)

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!

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jan 31, 2017 5:16 PM
(2985 views)

Solution

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

4 REPLIES

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Jan 31, 2017 5:16 PM
(2986 views)

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Aug 23, 2017 12:36 PM
(838 views)

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
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Aug 24, 2017 1:00 AM
(818 views)

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
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Aug 24, 2017 8:46 AM
(796 views)