I'm trying to make a new table by reading from two source tables. I'd like to avoid joining them into one big table and manipulating from there. The new table will be an array of deltas between the two source tables. The script is creating the columns just fine, but it's not populating them with anything. I'm assuming there's some syntax i'm missing in referencing columns from other tables in my formula.
predt = Open("C:\...\pre_data.jmp"); predtcols = predt << Get Column Names (string); postdt = Open("C:\...\post_data.jmp"); postdtcols = postdt << Get Column Names (string); dt = new table ("delta_values"); for (i=1, i <= NCols(predt), i++, dt << New column ("delta_"||predtcols[i], numeric, continuous, formula(postdt:column(postdtcols[i]) - predt:column(predtcols[i]))); );
You had a couple of issues that were byting(pun) you in the butt.
predt = data table("one");//Open( "C:\...\pre_data.jmp" ); predtcols = predt << Get Column Names( string ); postdt = data table("two");//Open( "C:\...\post_data.jmp" ); postdtcols = postdt << Get Column Names( string ); dt = New Table( "delta_values" ); dt << add rows(nrows(postdt)); For( i = 1, i <= N Cols( predt ), i++, Eval( Parse( "dt << New Column( \!"delta_" || predtcols[i] || "\!", numeric, continuous, formula( postdt:" || postdtcols[i] || "[Row()] - predt:" || predtcols[i] || "[Row()]) )'" ) ) ); dt << delete columns("column 1");
Thanks for the quick response! It looks like i'm only getting the first two columns' deltas with this script. The columns are formatted the same as the rest (numeric, continuous) so i'm not sure what's going on here.
I assume that it is a data issue. The code worked fine for my test case with 2 columns, but it is written to handle as many columns as it finds in the variable "predt"
For( i = 1, i <= N Cols( predt ), i++,
So, what you need to do, is to step through the code and check the variable values and see what is happening. Without your data being posted to this discussion, I don't know what is going on.
Are there any messages being displayed to the Log?
ah. it looks like all of my columns after column 2 have a (xxx) in the name - the units of the measurement. That could be it? The log is throwing an error for every column like that
The units (defined as a column property) are not part of the name of the column.
I imported the column names from and excel sheet (output of our tester), so I think they're buried in the column names