Choose Language Hide Translation Bar
Highlighted
skyzvoir0001
Level III

Loop

How do i loop through columns to make a summary table of means?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
txnelson
Super User

Re: Loop

I believe that all you need to do, is to use

     Tables==>Summary

and select all of the columns you want to generate means for and then click OK and the table will be produced.

If you need to do this using JSL, all you need to do, is to create a list of the columns you want the means for, and then use that in a call to the Summary Platform.

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

colList = dt << get column names( string, continuous );
Data Table( "semiconductor capability" ) << Summary(
	Mean( Eval( colList ) ),
	Freq( "None" ),
	Weight( "None" )
);
Jim

View solution in original post

2 REPLIES 2
Highlighted

Re: Loop

Your question is vague, so my answer might be likewise and 'miss the mark.'

 

Because you asked about looping, I assume that you are scripting. You could also interactively assign all of the numeric data columns to the Y role after selecting Analyze > Distribution to get the mean of all the variables. You could right-click on one of the tables and select Make Into Combined Data Table.

 

Here is one scripted solution:

 

Names Default to Here( 1 );

dt = Current Data Table();

name = mean = List();

For( col = 1, col <= N Col( dt ), col++,
	column = Column( dt, col );
	type = column << Get Data Type;
	If( type == "Numeric",
		Insert Into( name, Eval( Column( dt, col ) << Get Name ) );
		Insert Into( mean, Eval( Col Mean( Column( dt, col ) ) ) );
	);
);

New Table( "Column Means",
	New Column( "Name", "Character", "Nominal", Values( name ) ),
	New Column( "Mean", "Numeric", "Continuous", Values( mean ) ),
);

You should take more time to fully explain what you are trying to do and what help you need when you start a discussion if you expect to get a good answer without a lot of iterations.

Learn it once, use it forever!
Highlighted
txnelson
Super User

Re: Loop

I believe that all you need to do, is to use

     Tables==>Summary

and select all of the columns you want to generate means for and then click OK and the table will be produced.

If you need to do this using JSL, all you need to do, is to create a list of the columns you want the means for, and then use that in a call to the Summary Platform.

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

colList = dt << get column names( string, continuous );
Data Table( "semiconductor capability" ) << Summary(
	Mean( Eval( colList ) ),
	Freq( "None" ),
	Weight( "None" )
);
Jim

View solution in original post

Article Labels

    There are no labels assigned to this post.