Hi JMPBeginner,
**** Please refer to the attached .jsl file to see these scripts as intended. I have been having trouble getting my posts to display correctly, and if you copy/paste or type in the scripts that appear below, I am not sure if they will work. They look incorrect when I post them, but they look OK when I edit, so I am not sure what to do except attach a script file. My apologies!
*****
If you are willing to use value labels (for large tables, this can save a good deal of disk space, as well), you have another couple of speedy options:
1) A formula-based approach using the Contains() function:
dt << New Column( "y/n 2",
formula(
Contains(
{"A", "B", "C", "D", "E", "F", "G", "AA", "BB", "CC", "ZZ", "ABC", "DEC", "WSA", "RSS", "DVC", "SFS", "AAZ", "ZZA", "TTT"},
:MeasurementGroup
) != 0
),
<<Add Column Properties( value labels( {0, 1}, {"NO", "YES"} ) )
);
2) A non-formula based approach: JMP works with tables very quickly; the speed of this approach shocked me a little, given that a completely new table must be created and closed:
dt = Current Data Table();
dt2 = New Table( "mt", invisible );
Column( dt2, 1 ) << datatype( character ) << set name( "MeasurementGroup" ) << set values(
{"A", "B", "C", "D", "E", "F", "G", "AA", "BB", "CC", "ZZ", "ABC", "DEC", "WSA", "RSS", "DVC", "SFS", "AAZ", "ZZA", "TTT"}
);
dt2 << New Column( "y/n", <<set each value( 1 ) );
dt << New Column( "y/n", <<set each value( 0 ) );
dt << Update( With( dt2 ), Match Columns( :Measurement Group = :MeasurementGroup ), Add Columns from Update table( None ) );
Column( dt, "y/n" ) << Add Column Properties( value labels( {0, 1}, {"NO", "YES"} ) );
Close( dt2, nosave );
On a million row table, I was getting runtimes of ~ 2.4 seconds for the Match function. (MS's computer seems to be faster than mine ;-)
The runtimes of approach 1 above were ~ 0.8 seconds, while the runtimes of approach 2 were ~ 0.4 seconds.
Cheers,
Brady