Here's my attempt, the two tables at the bottom "stacked_table" and "summary_table_delta_by_wafer" might be the right shape for this.
It's fast at less than 1 second for the whole thing
(HP Time() - start) / 1000000 = 0.664238;
Names Default To Here(1);
dt_ref = Open("$DOWNLOADS/Reference data table.jmp", invisible);
dt_dt = Open("$DOWNLOADS/Data table.jmp", invisible);
dt_dt << clear select;
dt_ref << clear select;
start = Hp Time();
curr_col_names_list = dt_dt << Get Column Names("string");
obj = dt_dt << Tabulate(
Show Control Panel( 0 ),
Add Table(
Column Table(
Analysis Columns(
eval list(curr_col_names_list)
),
Statistics( Mean )
),
Row Table( Grouping Columns( :Wafer ID ) )
)
);
my_new_table = obj << Make Into Data Table;
curr_col_names_list = my_new_table << Get Column Names("string");
transposed_table = my_new_table << Transpose(
columns(
eval list(curr_col_names_list)
),
Label( :Wafer ID ),
Output Table( "transposed_table" )
);
transposed_table << new column ("join_key"
,char
,formula(
regex(:Label,"\(([^\)]+)\)", "\1")
)
);
transposed_table_join = (
transposed_table << Join(
With( dt_ref )
,Match Columns( :join_key = :Tests),
,Merge same name columns
,output table("transposed_table_join")
)
);
// clean up
close(transposed_table,nosave);
close(my_new_table,nosave);
transposed_table_join << delete columns(:"Match Flag", :"Label","join_key");
transposed_table_join:"Mean" << Set Name( "Ref_Value" );
curr_col_names_list = transposed_table_join << Get Column Names("string");
matches_i_dont_want_to_stack = {"Tests","Ref_Value"};
clean_col_list = Associative Array(curr_col_names_list) << Remove(Associative Array(matches_i_dont_want_to_stack)) << get keys;
stacked_table = transposed_table_join << Stack(
columns( clean_col_list ),
Source Label Column( "Wafer_ID" ),
Stacked Data Column( "Measured_Value" ),
Output Table( "stacked_table" )
);
//Is this the formula you wanted on each value? A-B?
stacked_table << new column ("delta"
,numeric
,continuous
,formula(
(:Ref_Value -:Measured_Value)
)
);
//stacked table and final summary_table_delta_by_wafer seems like the useful combo here.
close(transposed_table_join,nosave);
//final output?
summary_table_delta_by_wafer = stacked_table << Transpose(
columns( :delta ),
By( :Wafer_ID ),
Label( :Tests ),
Output Table( "summary_table_delta_by_wafer" )
);
show((Hp Time() - start)/1e6);