cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • DownloadSemiconductor Toolkit: Tools to create wafer maps, add wafer geometry to graphics, explore die defects & compare wafers.
  • Discovery Summit 2026: Early User Edition - September 23-24.Register. It's free.
  • See how to access JMP Marketplace - and - find, create & share add-ins to extend your JMP. Watch video.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
SpannerHead
Level VI

Try statement with Group Columns

I have a list of columns I want to group but the script fails if any of the columns are absent.  A try statement does not seem to fix the problem.

dt = Current Data Table();

Try( dt <<  Group Columns ("TM", {:Param_1, :Param_2, :Param_3}));

Slán



SpannerHead
2 ACCEPTED SOLUTIONS

Accepted Solutions
mmarchandFSLR
Level VI

Re: Try statement with Group Columns

If you want to group all columns present in that list (even if, say, :Param_2 is missing), you could try something like this.

 

Names Default To Here( 1 );
cols = {:a, :b, :c, :d, :e};
dt << Group Columns( "Some Columns", Filter Each( {v, i}, cols, dt << Has Column( Char( Name Expr( v ) ) ) ) );

View solution in original post

SpannerHead
Level VI

Re: Try statement with Group Columns

Had to tweak this a bit to identify dt.

Names Default To Here( 1 );
dt = Current Data Table();
cols = {:a, :b, :c, :d, :e};
dt << Group Columns( "Some Columns", Filter Each( {v, i}, cols, dt << Has Column( Char( Name Expr( v ) ) ) ) );

Slán



SpannerHead

View solution in original post

3 REPLIES 3
mmarchandFSLR
Level VI

Re: Try statement with Group Columns

If you want to group all columns present in that list (even if, say, :Param_2 is missing), you could try something like this.

 

Names Default To Here( 1 );
cols = {:a, :b, :c, :d, :e};
dt << Group Columns( "Some Columns", Filter Each( {v, i}, cols, dt << Has Column( Char( Name Expr( v ) ) ) ) );
SpannerHead
Level VI

Re: Try statement with Group Columns

Had to tweak this a bit to identify dt.

Names Default To Here( 1 );
dt = Current Data Table();
cols = {:a, :b, :c, :d, :e};
dt << Group Columns( "Some Columns", Filter Each( {v, i}, cols, dt << Has Column( Char( Name Expr( v ) ) ) ) );

Slán



SpannerHead
jthi
Super User

Re: Try statement with Group Columns

My suggestion would be to avoid :col and use strings. With JMP19 you can use Set Intersection

Names Default To Here(1); 

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

g = {"age", "sex", "height", "test", "test2"};

mycols = Set Intersection(dt << Get Column Names("String"), g);

dt << Group Columns("MyGroup", mycols);

In earlier versions Associative Arrays (or Filter Each) can replace Set Intersection

-Jarmo

Recommended Articles