Subscribe Bookmark RSS Feed

dt << Update // Syntax Risk!

robot

Community Trekker

Joined:

Feb 27, 2012

Hi,

I found a potentially dangerous "bug" in the Update function.  When updating a data table using "By Matching Columns", if the final "s" is omitted, this script will update by row.  This is an easy mistake to make, and difficult to catch (since no error is thrown).  Can this be addressed in the next JMP update?  This problem was found on JMP12.

Thanks!!

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

dt << New Column( "UniqueID",

       Character,

       Nominal,

       Formula( :name || ", " || Char( :age ) || ", " || :sex || ", " || Char( :height ) || ", " || Char( :weight ) )

);

dt << New Column( "Number", Numeric, Continuous, Format( "Best", 12 ), Formula( Sequence( 1, N Rows(), 1, 1 ) ) );

Column( dt, "UniqueID" ) << Delete Formula;

Column( dt, "Number" ) << Delete Formula;

dt2 = dt << Subset( Columns( "UniqueID", "Number" ) );

dt2 << Sort( Replace Table, By( :Number ), Order( Descending ) );

dt2 << New Column( "Some Column", Character, Nominal, Set Each Value( "x" ) );

dt << Update( With( dt2 ), By Matching Column( :UniqueID == :UniqueID ) );

//dt << Update( With( dt2 ), By Matching Columns( :UniqueID == :UniqueID ) );

dt << Bring Window to Front;

2 REPLIES
ron_horne

Super User

Joined:

Jun 23, 2011

Hi robot​,

I can confirm that it also happens in JMP11.

the issue persists even if you use "match column" instead. the truth is any combination of letters that are not "by Matching columns" or "match columns" causes JMP to ignor it and update by row (default unless stated by columns).

dt << Update( With( dt2 ), Match Column( :UniqueID == :UniqueID ) ); // still matching by row

// dt << Update( With( dt2 ), Match Columns ( :UniqueID == :UniqueID ) ); // this works fine - by columns

// dt << Update( With( dt2 ), Msfgsdfsfgatvvch Column ( :UniqueID == :UniqueID ) ); // no error message either - match by row

what a menace indeed.

the only comfort is that most people including me almost never write the update command but just get it from JMP after doing it manually. Otherwise, by now some nasty consequences would have floated. 

txnelson

Super User

Joined:

Jun 22, 2012

The requirement to have a specific, precise wording for JMP platforms, elements and messages is throughout JMP.  You have to be conscientious of correct specification of the syntax.

Jim