Subscribe Bookmark RSS Feed

Subset data table

blue1994

Contributor

Joined:

Feb 27, 2017

Hi all,

From my previous post, i face the subset data problem. I using the hard coding to list down the subset data table one by one.

But now i want dynamic the code, one of the reason that i don't want list down one by one(hard coding ) is if in future I have 50 F D in one dataset, so is impossible to me to list down the F D one by one right?

I try using the script below, but still have errors, and it only print the first f_d's subset data table for me only.

So, how can i do it to iterate until the 5 f_d?(because now i have 5 f_d)

Thanks.

dt = Open( <path to open data table>);


// Change the column name "F D" to "f_d"" to match the example
dt:F D << set name( "f_d" );
a = {"S_GX_F40", "S_GX_Z40","S_III_E110","S_III_E80","S_III_SL150"};
dt << Select Where( Starts With( :f_d, a[1] ) );
baseDT = dt << Subset( output table name( "Subset" ), selected rows( 1 ), selected columns( 0 ) );
For( i = 1, i <= N Items( a ), i++,
dt << Select Where( Starts With( :f_d, a ) );
TempDT = dt << Subset( output table name( "Subset" ), selected rows( 1 ), selected columns( 0 ) );
baseDT = baseDT << concatenate( TempDT, append to first table( 1 ) );
Close( TempDT, nosave );
);

 

1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales

Staff

Joined:

Mar 21, 2013

Solution

Is the column a character column? In the message there is no subscript on "a" which might mean it is a list rather than an element of the list.

dt = Open( "$sample_data/big class.jmp" );
letters = {"B", "C"};
dt << selectWhere( Starts With( dt:name, letters[2] ) );
dt << subset( selected rows( 1 ) );

Names starting with CNames starting with C

 

 

Craige
4 REPLIES
blue1994

Contributor

Joined:

Feb 27, 2017

It keep comes out with this error when i run the script:

argument should be character{1} in access or evaluation of 'Starts With' , Bad Argument( S ), Starts With/*###*/(:f_d, a)

So, how to I solve it?

Thanks.

 

Craige_Hales

Staff

Joined:

Mar 21, 2013

Solution

Is the column a character column? In the message there is no subscript on "a" which might mean it is a list rather than an element of the list.

dt = Open( "$sample_data/big class.jmp" );
letters = {"B", "C"};
dt << selectWhere( Starts With( dt:name, letters[2] ) );
dt << subset( selected rows( 1 ) );

Names starting with CNames starting with C

 

 

Craige
blue1994

Contributor

Joined:

Feb 27, 2017

Thanks Craige_Hales for reply.

But i now only can generate the individual subset data table.
How can i generate out all the subset data table? i have 5 f_d there, so i need generate out 5 subset data table.

In my coding, i have using loop, but it seems cannot functions.

Thanks 

blue1994

Contributor

Joined:

Feb 27, 2017

I have solve my subset data table problem already
Thanks.