Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
Jaz
Jaz
Level V

Merging Rows

Hi, 

 

I was just wondering if there was away to merge two rows from the same data table using JSL? I was contemplating using the Join function but I'm not entirely sure how that will work. 

 

Thanks. 

15 REPLIES 15
Highlighted
txnelson
Super User

Re: Merging Rows

You need to just try it.  Interactively join the table to it's self and see the results.  If you then open the "Source" entry in the Tables Panel on the left of the data table, you will see the JSL used to join the data table with it'self

Jim
Highlighted
dale_lehman
Level VI

Re: Merging Rows

I think you need to say more about your intent with merging rows.  I've had data sets where there were multiple rows that needed to be "combined" into a single observation.  How to do it depended on whether I wanted the average or sum (or....) of those rows.  Other times, there are just multiple rows with identical data and I want to eliminate the multiple observations.  So, I think you need to say why there are multiple rows to begin with and what you are attempting to reduce them to single rows for.

Highlighted
Jaz
Jaz
Level V

Re: Merging Rows

Hi, 

 

Basically I have two heading rows for each of my columns, the first is the main heading of the column and the second is the sub-heading of the column. I want to combine the heading and subheading rows so that they only take up one row. I'm aware I could do this by accessing values and replacing the contents of the first row and deleting the second but this seems like a very arduous task. I would much rather there be a concise function that could help me?

 

 

Highlighted
dale_lehman
Level VI

Re: Merging Rows

I'll leave it for someone better at scripting to answer your specific question.  But I've only had that particular issue occur when importing data from elsewhere (such as a spreadsheet or text file).  If that is the case, it is best solved at the file opening stage - you can change the open setting so that data starts on line 3 and the heading comprises 2 lines rather than 1.  It would seem odd to create a data set in JMP where the heading is put on two lines to start with.

Highlighted
Jaz
Jaz
Level V

Re: Merging Rows

Ok, thanks anyway. When I try opening via "Data With Preview" and try to enter the first two line numbers in the "Files contain column names on line: ", the wizard's won't let me enter two. Any suggestions?  

Highlighted
dale_lehman
Level VI

Re: Merging Rows

What kind of file are you opening?  If it is a text file, make sure the radio button says "data with preview" and if it is Excel then make the radio button for the "Always force row 1..." is set to Never.

Highlighted
Jeff_Perkinson
Community Manager Community Manager

Re: Merging Rows

Try the Column Name Utilities add-in by @XanGregg and @MikeD_Anderson.

 

It has tools for promoting a row into the column names. I think that might be what you're looking for.

-Jeff
Highlighted
chessknt87
Level I

Re: Merging Rows

My question is similar to this one I think.

 

My table has a column with repeating values but the rows have unique values and I am wondering if it is possible to consolidate the repeating rows in to a single row with new columns. Example below:

 

Subject   Value                Subject Value Value2

A              1                          A           1         2

A               2          ---->        B           3         4

B              3

B               4

Highlighted
txnelson
Super User

Re: Merging Rows

By using

     Tables==>Split

you will  be able to do what you want

or with

     Tables==>Transpose

Jim
Article Labels

    There are no labels assigned to this post.