This is by far not best practice. Using this generically with more files may question robustness.
If you need to repeat this more than once do yourself a favor and get a copy of the book: "Jump into jmp scripting". Most academic libraries have it.
Otherwise try this.
Names Default To Here( 1 );
// define the data source
dt = Current Data Table();
//stack the data so all tests are in one column
dtstack = dt << Stack(
columns( :Test 1, :Test 2 ), // add to this all your tests columns
Source Label Column( "Label" ),
Stacked Data Column( "Data" )
);
// get the unique values for Lab
laboratry = Associative Array( dtstack:lab ) << get keys;
// get unique values for tests
test = Associative Array( dtstack:Label ) << get keys;
// define a results table
dt1 = New Table( "results",
New Column( "Lab", character, nominal ),
New Column( "Test", character, nominal ),
New Column( "Mean" ),
New Column( "SD" ),
);
// loop through labs ans tests in the stack data table to extract results.
For( i = 1, i <= N Items( laboratry ), i++,
For( it = 1, it <= N Items( test ), it++,
labtestrows = dtstack << get rows where( And( dtstack:Lab == laboratry[i], dtstack:Label == test[it] ) );
dt1 << add rows( 1 );
dt1:Lab[N Row( dt1 )] = laboratry[i];
dt1:Test[N Row( dt1 )] = test[it];
dt1:Mean[N Row( dt1 )] = Meanlabtest1 = Mean( dtstack:Data[labtestrows] );
dt1:SD[N Row( dt1 )] = SDlabtest1 = Std Dev( dtstack:Data[labtestrows] );
)
);
// close the results table and save as excell
Close( dt1, save( "D:\My Documents\results.xlsx" ) );