Here are some ways to do this:
- Table Operations:
- Stack the columns in to one column using Tables > Stack
- Use Tables > Summary with that stacked column as the Group role
- JSL
- Get column values into a list
- list_of_values = column(table name, column name) << get values
- You can do this again on another column and insert those values into the list
- list_of_values = Insert Into(list_of_values, column(table name, another column name) << get values)
- repeat as necessary
- Use an Associate Array to get the unique values
- unique_values = (Associative Array(list_of_values)) << get keys
- put that list of values into a new column in a data table
Names Default To Here( 1 );
// create table with 4 columns with random letters
nr = 20;
dt = New Table( "Example", addrows( nr ) );
letterlist = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q",
"R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
dt << New Column( "C1", character );
Column( dt, "C1" ) << set values( letterlist[J( nr, 1, Random Integer( 26 ) )] );
dt << New Column( "C2", character );
Column( dt, "C2" ) << set values( letterlist[J( nr, 1, Random Integer( 26 ) )] );
dt << New Column( "C3", character );
Column( dt, "C3" ) << set values( letterlist[J( nr, 1, Random Integer( 26 ) )] );
dt << New Column( "C4", character );
Column( dt, "C4" ) << set values( letterlist[J( nr, 1, Random Integer( 26 ) )] );
// Method 1
dtstack = dt << Stack(
columns( :C1, :C2, :C3, :C4 ),
Source Label Column( "Label" ),
Stacked Data Column( "Data" ),
Output Table( "Stacked Values" )
);
dtstack << Summary(
Group( :Data ),
Freq( "None" ),
Weight( "None" ),
output table name( "Unique Values" )
);
//Method 2
list_of_values = Column( dt, "C1" ) << get values;
Insert Into( list_of_values, Column( dt, "C2" ) << get values );
Insert Into( list_of_values, Column( dt, "C3" ) << get values );
Insert Into( list_of_values, Column( dt, "C4" ) << get values );
Print( list_of_values );
unique_values = (Associative Array( list_of_values )) << get keys;
dtunique = New Table( "Unique Values" );
dtunique << New Column( "Unique Values", character );
Column( dtunique, "Unique Values" ) << set values( unique_values );