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
SING
Level II

How to select columns which start with specific names in JSL?

Hello, 

I have some problem when I want to select some specific columns.

 

If there have column header with "RD123", "RD345", "123RD"...etc.

I want to select the column only start with "RD", and the only script I know is below

 

dt = Current Data Table();
colList= dt << get column names( string );
For( i = 1, i <= N Items( colList ), i++,
If( Contains(colList [i], "RD")) << set selected)
);

 

How to modify the script to select only "RD123" and "RD345"? 

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: How to select columns which start with specific names in JSL?

You could use Starts With instead of Contains. Also it might be easier to first filter down to the list of columns of interest and then select those using << Select Columns. Below is one example

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");

all_colnames = dt << Get Column Names("String");
cols_of_interest = Filter Each({col_name}, all_colnames, Starts With(col_name, "NPN"));

dt << Select Columns(cols_of_interest);
-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: How to select columns which start with specific names in JSL?

You could use Starts With instead of Contains. Also it might be easier to first filter down to the list of columns of interest and then select those using << Select Columns. Below is one example

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");

all_colnames = dt << Get Column Names("String");
cols_of_interest = Filter Each({col_name}, all_colnames, Starts With(col_name, "NPN"));

dt << Select Columns(cols_of_interest);
-Jarmo
SING
Level II

Re: How to select columns which start with specific names in JSL?

Thanks a lot!

Recommended Articles