cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Image to Table JMP extension imports single or batch images as data tables. Useful to extract curves from pictures or convert image data to curve data to use in analyses like Functional Data Explorer. Download and install the extension.

Discussions

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

I need to group columns using contain function of column name.

I am trying to group a Column by a contain function of column name. I need to group every column that contain "ID". Here is what I came up with. What am I doing wrong?

ConfidenceOwl94_0-1740152128452.png

 

<JSL>

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Air Traffic.jmp" );

Data Table( "Air Traffic" ):Event << Set Name( "ID" );

col = dt << get column names( "String");
nc = N Items( col );
colList = {};

For( i = 1, i <= nc, i++,
If(Contains (col[i] ,"ID"),
Insert Into( colList, col[i] ))
);

Print(ColList);

dt << Group Columns( "ID", ColList );
1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: I need to group columns using contain function of column name.

At least JMP won't like that you have same name for column and group

Names Default To Here(1);
dt = Open("$SAMPLE_DATA\Air Traffic.jmp");

Column(dt, "Event") << Set Name("ID");
colnames = dt << get column names("String");

idcols = Filter Each({colname}, colnames, Contains(colname, "ID"));

dt << Group Columns("ID_GROUP", idcols);
-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: I need to group columns using contain function of column name.

At least JMP won't like that you have same name for column and group

Names Default To Here(1);
dt = Open("$SAMPLE_DATA\Air Traffic.jmp");

Column(dt, "Event") << Set Name("ID");
colnames = dt << get column names("String");

idcols = Filter Each({colname}, colnames, Contains(colname, "ID"));

dt << Group Columns("ID_GROUP", idcols);
-Jarmo

Re: I need to group columns using contain function of column name.

Thanks Jarmo,

As usual you are a life saver. Thanks for the alternative solution. 

Recommended Articles