cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
Get the free JMP Student Edition for qualified students and instructors at degree granting institutions.
Choose Language Hide Translation Bar
View Original Published Thread

Getting the items of a character column as a list

RA899
Level IV

Hi all, 

I'm simply trying to get a character column as a list. The column has duplicate entries and I would like a function that returns only the unduplicated rows. I tried using the "Get as matrix" function along with the " as column" function, but I kept getting different errors. 

 

Any help is appreciated. Thanks.

2 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User


Re: Getting the items of a character column as a list

The easiest way I know to do this is with an Associative Array

names default to here(1);

dt = 
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );

uniqueValues = associative array(dt:sex)<<get keys;
Jim

View solution in original post

jthi
Super User

Re: Getting the items of a character column as a list

There are few different options all with their own disadvantages and advantages. Some are slower/faster, some take more code to write,... I usually use Summarize() 

Names Default To Here(1); 

dt = open("$SAMPLE_DATA/Big Class.jmp");

// Use associative array + get keys (slowest)
uniqnames1 = Associative Array(Column(dt, "name")) << get keys;

// Use summarize (will convert numeric values to characters)
Summarize(dt, uniqnames2 = By(:name));

// Use summary + data table subscripting (or get values)
dt_summary = dt << Summary(
	Group(:name),
	Freq("None"),
	Weight("None"),
	Link to original data table(0),
	private
);

uniqnames3 = dt_summary[0, "name"];
uniqnames4 = Column(dt_summary, "name") << get values;
Close(dt_summary, no save);



Show(uniqnames1, uniqnames2, uniqnames3, uniqnames4);
-Jarmo

View solution in original post

2 REPLIES 2
txnelson
Super User


Re: Getting the items of a character column as a list

The easiest way I know to do this is with an Associative Array

names default to here(1);

dt = 
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );

uniqueValues = associative array(dt:sex)<<get keys;
Jim
jthi
Super User

Re: Getting the items of a character column as a list

There are few different options all with their own disadvantages and advantages. Some are slower/faster, some take more code to write,... I usually use Summarize() 

Names Default To Here(1); 

dt = open("$SAMPLE_DATA/Big Class.jmp");

// Use associative array + get keys (slowest)
uniqnames1 = Associative Array(Column(dt, "name")) << get keys;

// Use summarize (will convert numeric values to characters)
Summarize(dt, uniqnames2 = By(:name));

// Use summary + data table subscripting (or get values)
dt_summary = dt << Summary(
	Group(:name),
	Freq("None"),
	Weight("None"),
	Link to original data table(0),
	private
);

uniqnames3 = dt_summary[0, "name"];
uniqnames4 = Column(dt_summary, "name") << get values;
Close(dt_summary, no save);



Show(uniqnames1, uniqnames2, uniqnames3, uniqnames4);
-Jarmo