cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
chandankishor66
Level III

Calculate mean and standard deviation for each columns

Is there any way write a script to calculate mean and standard deviation for each columns and put them in new columns.

 

chandankishor66_0-1691391120980.png

The test data is attached here.

2 REPLIES 2
jthi
Super User

Re: Calculate mean and standard deviation for each columns

Easiest is most likely to stack your data, add new columns for statistics and then split the data again if needed.

-Jarmo
txnelson
Super User

Re: Calculate mean and standard deviation for each columns

One way to solve this issue, is to use the Tabulate Platform to generate the statistics, and then to use 

     Tables=>Update

to attach the new statistics data table to the original table.

Both the Tabulate Platform and Update Platform surface the JSL, so only minor modifications had to be made to put the 2 pieces of JSL together into one script.

names default to here(1);
dt = data table("test-data");
colList = dt << get column names(string);

dtSum = (Data Table( "test-data" ) << Tabulate(invisible,
	Add Table(
		Column Table(
			Analysis Columns(
				eval( colList )
			)
		),
		Row Table( Statistics( Mean, Std Dev ) )
	)
)) << Make Into Data Table;
dtsum = current data table();

window("test-data - Tabulate") << close window;

for each( {col}, colList,
	as column( dtSum, col) << set name( col || " Statistics")
);

Data Table( "test-data" ) << Update( dtSum ) );

close( dtSum, nosave );

I strongly suggest that you take the time to read the Scripting Guide to enhance your JMP expertise. 

Jim