cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • We’re improving the Learn JMP page, and want your feedback! Take the survey
  • JMP monthly Newswire gives user tips and learning events. Subscribe
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