Pretty common data prep step for stability data at multiple storage conditions. As described below, the general procedure to do this is:
- Summarize the storage conditions into a separate table.
- Past those conditions at the end of the original table, and set the time point for those rows to be the initial time point.
- Calculate the average response(s) at the starting time point, and use that value for all the pasted rows above.
- Delete or Hide/Exclude the original initial timepoints from the data table.
I just happened to recently finish a script to help automate this (provided with no guarantee or warranty).
Names Default To Here( 1 );
// utility to replicate stability condition labels and variables at time Zero for each stabilty condition
dt = Current Data Table();
timelistdisplay = 0;
nw = New Window( "Replicate Initial Time Point Results Across Conditions",
hb = H List Box(
pb_1 = Panel Box( "Select Columns", clb_1 = Col List Box( all ) ),
pb_2 = Panel Box( "Case Column into Role",
lub_variables = Lineup Box( N Col( 2 ),
Button Box( "Time Column",
Try(
clb_time << append( clb_1 << get selected );
c_time_name = (clb_time << get items)[1];
);
c_time = Column( dt, c_time_name );
time_list = Associative Array( As List( (c_time << get values) ) ) << get keys;
For Each( {s, i}, time_list, time_list[i] = Char( s ) );
If( !timelistdisplay,
pb_2 << Append(
hb_timelist = H List Box( Text Box( "Initial Time Point to Replicate" ), combox = Combo Box( {} ) )
);
timelistdisplay = 1;
);
combox << set items( time_list );
),
clb_time = Col List Box( "numeric", Max Items( 1 ), nlines( 1 ), minItems( 1 ) ),
Button Box( "Stability Condition Columns", clb_stabcond << append( clb_1 << get selected ) ),
clb_stabcond = Col List Box( Min Items( 1 ), nLines( 4 ) ),
Button Box( "Response Columns", clb_response << append( clb_1 << get selected ) ),
clb_response = Col List Box( minItems( 1 ), nlines( 5 ) ),
)
),
pb_3 = Panel Box( "Actions",
V List Box(
Button Box( "OK",
responsecols = clb_response << get items;
// check that all boxes are populated and if so, then do actions
If(
N Items( clb_time << get items ) & N Items( clb_stabcond << get items ) &
N Items( clb_response << get items ),
// make list of column references for the stability condition columns
dt << clear select;
Eval(
Substitute(
Expr(
dt << select where( As Column( dt, c_time_name ) != vvv )
),
Expr( vvv ),
Num( combox << get selected )
)
);
dt_sub = dt << Subset( Selected Rows( 1 ), Selected columns only( 0 ) );
stab_cond_col_list = {};
For Each( {s, i}, clb_stabcond << get items, Insert Into( stab_cond_col_list, Column( dt, s ) ) );
dt_summary = dt_sub << Summary(
Group( stab_cond_col_list ),
Freq( "None" ),
Weight( "None" ),
Link to original data table( 0 ),
output table name( "Stability Conditions" )
);
dt_summary << delete columns( :N Rows );
Close( dt_sub, nosave );
cnew = dt_summary << New Column();
cnew << set name( c_time_name );
timezero = Num( combox << get selected );
cnew << Set Values( J( N Row( dt_summary ), 1, timezero ) );
dt << clear select;
// get the results for time zero
Eval(
Substitute(
Expr(
dt << select where( As Column( dt, c_time_name ) == vvv )
),
Expr( vvv ),
Num( combox << get selected )
)
);
// add those to the summary table of conditions
For Each( {rc}, responsecols,
val = Mean( Column( dt, rc )[dt << get selected rows] );
c = dt_summary << New Column( rc );
c << set values( J( N Rows( dt_summary ), 1, val ) );
);
// hide and exclude the initial values results in the first table
dt << hide and exclude;
dt << clear select;
// now concatenate the summary table onto the original table.
dt << Concatenate( dt_summary, Append to first table );
close(dt_summary, nosave);
nw<<close window;
)
;
),
Button Box( "Remove",
// check time variable
temp = clb_time << get selected;
If( N Items( temp ),
clb_time << remove selected;
timelistdisplay = 0;
hb_timelist << delete;
);
// stability condition
clb_stabcond << remove selected;
clb_response << remove selected;
),
Button Box( "Cancel", nw << close window )
)
)
)
);
Example: (also attached)
Dialog:
Result: