cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • 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
peter_t
Level II

How do I get rows based on dynamic column selection in JSL

In a JMP script I would like to retrieve the rows matching a certain criteria specified by user. I would like to do something similar to this:

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
r = dt << Get Rows Where( :sex == "M" );
Show( r );

Only where the criteria is selected by the user, i.e. the column ("sex") and the target value ("M") should be dynamic. I have tried this without luck:

colname=Column(dt,"sex");
target="M";
r2 = dt << Get Rows Where( colname == target );
show(r2);

What am I doing wrong?

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: How do I get rows based on dynamic column selection in JSL

Issue is with your colname

 

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");

colname = Column(dt, "sex");
target = "M";
r2 = dt << Get Rows Where(As Column(colname) == target);
Show(r2);

or in my opinion better option

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");

colname = "sex";
target = "M";

r2 = dt << Get Rows Where(As Column(dt, colname) == target);
Show(r2);

or

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");

colname = "sex";
target = "M";

r2 = dt << Get Rows Where(Column(dt, colname)[Row()] == target);
Show(r2);

 

-Jarmo

View solution in original post

1 REPLY 1
jthi
Super User

Re: How do I get rows based on dynamic column selection in JSL

Issue is with your colname

 

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");

colname = Column(dt, "sex");
target = "M";
r2 = dt << Get Rows Where(As Column(colname) == target);
Show(r2);

or in my opinion better option

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");

colname = "sex";
target = "M";

r2 = dt << Get Rows Where(As Column(dt, colname) == target);
Show(r2);

or

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");

colname = "sex";
target = "M";

r2 = dt << Get Rows Where(Column(dt, colname)[Row()] == target);
Show(r2);

 

-Jarmo

Recommended Articles