cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Use World Cup data to build models, explore spatial relationships, and create informative visualizations in JMP. Register. July 17, 2 pm US Eastern Time.
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

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