BookmarkSubscribeRSS Feed
txnelson

Super User

Joined:

Jun 22, 2012

Solution

Re: Running average by data series using For Loop and same script on multiple columns

Below is a script that create the summary output table you stated was what you wanted.  The script goes from the JMP data table you provided, through to it's completion.  About 80% of the script was actually created by running the steps interactively in JMP, and then just having JMP save the script it used for the interactive processing to a script window.  All of the steps and functions used in the script are documented in the Scripting Guide and Scripting Index

     Help==>Books==>Scripting Guide

     Help==>Scripting Guide

Names Default To Here( 1 );
dt = Current Data Table();

// Correct the data table using the JMP table imported from the Excel file
For( i = 2, i <= N Cols( dt ), i++,
	Column( dt, i ) << set name(
		Word( 1, Column( dt, i ) << get name, " " ) || " " || Column( dt, i )[1]
	)
);

dt << delete rows( 1 );

For( i = 2, i <= N Cols( dt ), i++,
	Column( dt, i ) << data type( numeric ) << modeling type( continuous )
);

// Change the name of the first column to H(Oe)
Column( dt, 1 ) << set name( "H(Oe)" );

// Create a list of all numeric column names
colNamesList = dt << get column names( numeric );

// Summarize the data
dtSum = dt << Summary(
	Mean( Eval( colNamesList ) ),
	Freq( "None" ),
	Weight( "None" ),
	statistics column name format( "column" ),
	Link to original data table( 0 )
);

// Create final table and sort it in alphabetical order

// First delete the unneeded column N Rows
dtSum << delete columns( "N Rows" );

dtFinal = dtSum << Transpose(
	columns( Eval( colNamesList ) ),
	Label column name( "Column" ),
	Output Table( "Summary " )
);

// Change the name of the "Row 1" column to "Mean"
dtFinal:Row 1 << set name( "Mean" );

// Sort the data table
dtFinal = dtFinal << sort( by( Column ), order( Ascending ), Replace Table( 1 ) );
Jim
tylerram123

Occasional Contributor

Joined:

Dec 4, 2018

Re: Running average by data series using For Loop and same script on multiple columns

I still can't output in a journal. I am trying this right now, but no luck.

 

 

jrn = New Window( "Reports", <<Journal );

jrn << Append( H List Box( (dtFinal << Report) ) ) ;

jrn <<Save Journal(("C:\!Destination!\Output.jrn") ) ;

uday_guntupalli

Community Trekker

Joined:

Sep 15, 2014

Re: Running average by data series using For Loop and same script on multiple columns

@tylerram123,
          Can you help me understand what you need this journal for ?  Try this example. I tested it and this will work. 

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
MyJrn = dt << journal;
Best
Uday
Highlighted
tylerram123

Occasional Contributor

Joined:

Dec 4, 2018

Re: Running average by data series using For Loop and same script on multiple columns

The excel sheet I am using and recieving has six tabs and I want to consildate all the data into one journal so I can send it off or do more analysis. Thanks!