cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Learn how to build custom Python data connectors and further customize JMP’s Data Connector Framework with the Python Data Connector Demo, available now in the JMP Marketplace!
  • See how to create experiments to support product design and ID useful product features. Register for June 12 webinar, 2pm US Eastern Time.

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