cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
BHarris
Level VI

Where are associative arrays stored?

Suppose in JSL I create an associative array, then create a new column in a data table with a formula that uses that array to populate the column based on entries in another column.

 

When the data table is saved, it seems to hold onto that associative array somewhere -- where is it stored?  Within the data table somewhere?  Is there a way to see it or edit it later?

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Where are associative arrays stored?

The associative array is saved in RAM Memory until the variable is cleared, or the Name Space it is in is closed or the JMP session is closed.  What you might be seeing that makes you think the array is being saved, is a couple things.

  1. When you open the data table, it will show the values in the formula column that existed when the data table was saved.  The formula is not run to achieve this, it appears that the last values are saved with the column.  But if you attempt to add a new row to the data table, which will force the formula to run, there will be an error displayed.
  2. If you save and close the data table and then open it again, without closing out the JMP session, the formula may find the array still remaining in RAM memory.  Thus, it allows the formula to run.

The way that I typically handle formulas that need such items as an Associative Array, is to add the creation of the array into the formula, executing it only when the formula is first run.  A real simple example would be:

If the Associative Array is created with this formula.

myArray = associative array(:age << get values);

Then to make it work in a formula you would just specify to run this code only when the formula is running the first row, thus making it available to all of the rows

If( Row() == 1,
	myArray = Associative Array( :age << get values )
);

With this JSL as the first item in your formula, the formula will work.

Jim

View solution in original post

1 REPLY 1
txnelson
Super User

Re: Where are associative arrays stored?

The associative array is saved in RAM Memory until the variable is cleared, or the Name Space it is in is closed or the JMP session is closed.  What you might be seeing that makes you think the array is being saved, is a couple things.

  1. When you open the data table, it will show the values in the formula column that existed when the data table was saved.  The formula is not run to achieve this, it appears that the last values are saved with the column.  But if you attempt to add a new row to the data table, which will force the formula to run, there will be an error displayed.
  2. If you save and close the data table and then open it again, without closing out the JMP session, the formula may find the array still remaining in RAM memory.  Thus, it allows the formula to run.

The way that I typically handle formulas that need such items as an Associative Array, is to add the creation of the array into the formula, executing it only when the formula is first run.  A real simple example would be:

If the Associative Array is created with this formula.

myArray = associative array(:age << get values);

Then to make it work in a formula you would just specify to run this code only when the formula is running the first row, thus making it available to all of the rows

If( Row() == 1,
	myArray = Associative Array( :age << get values )
);

With this JSL as the first item in your formula, the formula will work.

Jim