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

Sum of all rows into a list

I'm trying to take the sum of all of my rows and add it to a list.  So, the sum of row 1 will be item 1, sum of row 2 will be item 2, etc.  Is there an easy way to do this using jsl?

2 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User

Re: Sum of all rows into a list

Here is one way to do it.  Others may have better methods

Names Default To Here( 1 );
dt = Current Data Table();
sumMatrix = [];
For Each( {col}, dt << get column names( string, numeric ),
	sumMatrix = sumMatrix || Col Sum( Column( dt, col ) )
);
Jim

View solution in original post

jthi
Super User

Re: Sum of all rows into a list

You can also use matrix calculations, below is one option

Names Default To Here(1); 

dt = open("$SAMPLE_DATA/Big Class.jmp");

m = dt << get as matrix;

sums = V Sum(m`);

tolist = As List(sums)[1];
-Jarmo

View solution in original post

3 REPLIES 3
txnelson
Super User

Re: Sum of all rows into a list

Here is one way to do it.  Others may have better methods

Names Default To Here( 1 );
dt = Current Data Table();
sumMatrix = [];
For Each( {col}, dt << get column names( string, numeric ),
	sumMatrix = sumMatrix || Col Sum( Column( dt, col ) )
);
Jim
wyler00
Level I

Re: Sum of all rows into a list

Thank you.  Both of your solutions work great.

jthi
Super User

Re: Sum of all rows into a list

You can also use matrix calculations, below is one option

Names Default To Here(1); 

dt = open("$SAMPLE_DATA/Big Class.jmp");

m = dt << get as matrix;

sums = V Sum(m`);

tolist = As List(sums)[1];
-Jarmo

Recommended Articles