注意:The strategy described here is not useful for columns with floating point numbers. Use Summarize instead. See “Store Summary Statistics in Global Variables” on page 336 in the “Data Tables” chapter.
A key can exist only once in an associative array, so putting a column’s values into one automatically results in the unique values. For example, the Big Class.jmp sample data table contains 40 rows. To see how many unique values are in the column height, run this script:
unique heights = Associative Array( dt:height );
There are only 17 unique values for height. You can use those unique values by getting the keys:
unique heights << Get Keys;
nms = dt:name << Get Values;
Wait( 0 );
t1 = Tick Seconds();
Because keys are ordered lexicographically, putting the values into an associative array also sorts them. For example, the <<Get Keys message returns the keys (unique values of the names column) in ascending order:
unique names = Associative Array( dt:name );
unique names << Get Keys;
aa1 = Associative Array( dt1:Country );
aa2 = Associative Array( dt2:Territory );
Use N Items() to see how many countries appear in each data table:
N Items(aa1);
N Items(aa2);
Use the <<Intersect message to find the common values:
aa1 = Associative Array( dt1:Country );
aa1 << Intersect( aa2 );