cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
] />

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
hyue
Level I

Converting Between Data Tables and Associative Arrays

Hi there,

 

Is there a simple way to convert a data table to an associative array?  I'm trying to pass the associative array to an external API for analysis, and then getting the results back into JMP as a data table afterwards.

 

Thanks!

 

Howard

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Converting Between Data Tables and Associative Arrays

Check the scripting index (Help > Scripting Index).  The AA will accept a matrix or a list as an input when you create it.  So, the easiest way would be to get your Key column as a list, your value column as a list, and pass those to the AA command as the Keys and Values.  

 

If you want to get multiple columns into your Value for a given Key you can do that too.  There are some great examples in the scripting guide (Help > Books > JMP Scripting Guide).  You can also look at the code I use here: Total Recall: A new strategy for Recall support in JMP applications for some examples on how I work with AA's.

 

M

 

 

View solution in original post

3 REPLIES 3

Re: Converting Between Data Tables and Associative Arrays

Check the scripting index (Help > Scripting Index).  The AA will accept a matrix or a list as an input when you create it.  So, the easiest way would be to get your Key column as a list, your value column as a list, and pass those to the AA command as the Keys and Values.  

 

If you want to get multiple columns into your Value for a given Key you can do that too.  There are some great examples in the scripting guide (Help > Books > JMP Scripting Guide).  You can also look at the code I use here: Total Recall: A new strategy for Recall support in JMP applications for some examples on how I work with AA's.

 

M

 

 

hyue
Level I

Re: Converting Between Data Tables and Associative Arrays

Thanks, M.  That was a good idea and I have implemented it.

 

Howard

Desert_Rose
Level I

Re: Converting Between Data Tables and Associative Arrays

I recently needed to convert datatable to associative array. Below is what I did

/********************************************** table to associative array ***************************************************/
dt = Current Data Table();
pe_steps = Associative Array();
ForEach( {i}, 1::ncols(dt),	pe_steps[Column(dt,i) << get name] = Column(dt,i) << get values );
Show( pe_steps );
/********************************************** table to associative array ***************************************************/

Recommended Articles