cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
jade
Level III

How to store data in a list?

Hi everyone,

I face a problem on how to store the subset data table into a list, below is my code :

dt = Open (<path of file>);


p= {"G_40", "F_45", "E_57", "F_85", "H_90"};

For( i = 1, i <= N Items( p ), i++,
dt << Select Where(Starts With( dt:ftf, p[i] ) ) ;

tempDT = dt << Subset( output table name( "Subset" ), selected rows( 1 ), selected columns( 0 ), "invisible");
);

I plan to store tempDT into the empty list, Anyone has an idea on the store function? I very new to JSL if in python we will use append function to store, then how about jsl?

Because when i scratch out the script, then run the script, it can generate out all the subset data table but when i want to plot chart, it only generate out the chart for the last subset data table.  So, anyone can give me some idea on how to work it

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales
Super User

Re: How to store the data into list

Ian's answer is a much better approach than using a list. In the list apporach you have mutiple for-loops, one to build the list, and one (or more) to process the list. Ian is doing all the processing in a single for-loop, creating a graph and moving it to its final destination. He's also only creating one subset at a time, and closing it as soon as he is done with it. There's another advantage to Ian's approach: the meta-data about the subset is still available--you know the parameters used to create the subset have not changed.

Craige

View solution in original post

8 REPLIES 8
txnelson
Super User

Re: How to store the data into list

The documentation for handling lists is located in the Scripting Guide for JMP 13, on page 161.

     Help==>Books==>Scripting Guide==>Working with Collections of Data

 

The real question that you need to deal with is the fact that your code is creating each different subset table with the same handle and the same data table name.  Since JMP can not have 2 data tables with the same name, it will change the name for the second, third.......data tables.  So you need to figure out how to handle such changes.

Jim
jade
Level III

Re: How to store the data into list

Thanks JIm for the response.
I have try using the associative array function, but it keep comes out error. Is there any function of JSL can solve my problem in order to edit my script?
Thanks
txnelson
Super User

Re: How to store the data into list

Are you looking to store the complete data table into the associative array, or as you specified in your earlier response, into a List?  I was assuming that you just wanted to save the data table pointer or name to a list.  Can you please clarify?

Jim
jade
Level III

Re: How to store the data into list

HI, jim
Actually I want save the data table pointer to a list.
But I don't know how to point into the list, I have check the scripting guide book, and try write out the script, but it still cannot.
So, i'm trying using another method, but it still comes out error.
so, I really don't know how to store the data table into list.
Very sorry here, can you give me some hint on how to do it,?
Thanks.
txnelson
Super User

Re: How to store the data into list

If you look at page 167 int the Scripting Guide, it will show you the different ways to asiging items into a list.  You should be able to find a simple way to do that.  Subscripting or Inserting are likly candidates I would think

Jim
Craige_Hales
Super User

Re: How to store the data into list

I'd usually create the reports inside the same for loop that creates the subsets and close the subsets as soon as they were no longer needed. But you can create a list of open subsets then send the list a message. Internally, the list will repeat the message to each item in the list.

dt = Open( "$sample_data/big class.jmp" );
p = {"A", "B", "C", "D", "E"};
tableList = {};
For( i = 1, i <= N Items( p ), i++,
    dt << Select Where( Starts With( dt:Name, p[i] ) );
    tempDT = dt << Subset( output table name( "Subset" ), selected rows( 1 ), selected columns( 0 ), "invisible" );
    Insert Into( tableList, tempDT );
);

tableList << Distribution( y( name, height ) );

Wait( 3 );
For( i = 1, i <= N Items( tablelist ), i++,
    Close( tableList[i], nosave )
);

Close( dt, nosave );

You'll still want a loop to close the subset tables when you are done with them.

Craige
Craige_Hales
Super User

Re: How to store the data into list

Ian's answer is a much better approach than using a list. In the list apporach you have mutiple for-loops, one to build the list, and one (or more) to process the list. Ian is doing all the processing in a single for-loop, creating a graph and moving it to its final destination. He's also only creating one subset at a time, and closing it as soon as he is done with it. There's another advantage to Ian's approach: the meta-data about the subset is still available--you know the parameters used to create the subset have not changed.

Craige
jade
Level III

Re: How to store the data into list

Thanks you all for the replying.
It's very helpful.