Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
ENTHU
Level III

Referencing to a specific data table

Hi,

 

I have a data table dtValues.I have sorted the data table as follows -

dtValues << Sort(
By( :test_end_date_1 ),
Order( Ascending ),
Output Table( "out_sorted" )
);

 

Now I want to get unique values from a column "weight" from the out_sorted table.

I tried the following code -

unique_wt = {};
unique_wt = Associative Array( dtValues:weight ) << Get Keys

But this code gives unique values from the table before sorting.I am looking for weight values from the sorted table.

How do I get around this?

 

 

4 REPLIES 4
Highlighted
txnelson
Super User

Re: Referencing to a specific data table

You need to set a pointer to the new data table that is being created.  The below code does that:

dtSorted = dtValues << Sort(
	By( :test_end_date_1 ),
	Order( Ascending ),
	Output Table( "out_sorted" )
);
 

unique_wt = {};
unique_wt = Associative Array( dtSorted:weight ) << Get Keys;
Jim
Highlighted
ENTHU
Level III

Re: Referencing to a specific data table

Thanks for the response.

But looks like 

unique_wt = Associative Array( dtSorted:weight ) << Get Keys;

outputs the key in ascending order by default.

I wanted to get the weight values in the order they appear in the column and not in ascending order.

Is there any other way to achieve this?

 

Thanks

Highlighted
txnelson
Super User

Re: Referencing to a specific data table

The following quote is taken from the Scripting Guide, in reference to Associative Arrays

 

• Though associative arrays are not usually ordered, in JMP, keys are returned in
   alphanumeric order for the purpose of iteration and serialization.

Jim
Highlighted
ENTHU
Level III

Re: Referencing to a specific data table

Is there a work around for this? Like may be get all the values in the column and remove duplicates?

Without using associative arrays that is.

Article Labels

    There are no labels assigned to this post.