cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
weilyne
Level I

How do i Stack newly created column without specified naming

num_columns = 3;
col_names = Associative Array();
For(i = 1, i <= num_columns, i++,col_name = Char(400 + (i - 1) * 100);ATOM0TABLE << New Column(col_name, Character, Nominal, formula(Word(i, :FINAL_RESULT, "_"), ""));
col_names[i] = col_name);
stacktable = ATOM0TABLE << Stack(
   Columns ( col_names),  // List of columns to stack
   Source Label Column("Label"), Stacked Data Column("Data"),
   Output Table("stacktable"));

Was trying to create 3 columns with column name 400 and continuously till 600 and gonna stack those newly column. It works fine till creating the column but not able to stack the column as is showing "Column not found in access or evaluation of 'Bad Argument'

Empty()"

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: How do i Stack newly created column without specified naming

You are trying to use Associative Array as input for << Stack. You can get the values from associative array by using << Get Values. (thought un this case it might be better to use list).

Names Default To Here(1);

dt = New Table("",
	Add Rows(1),
	New Column("FINAL_RESULT", Character, Nominal, Values({"TEST1_TEST2_TEST3"}))
);

num_columns = 3;
col_names = {};

For(i = 1, i <= num_columns, i++,
	col_name = Char(400 + (i - 1) * 100);
	new_col = dt << New Column(col_name, Character, Nominal, formula(Word(i, :FINAL_RESULT, "_"), ""));
	Insert Into(col_names, new_col << get name);
);

stacktable = dt << Stack(
	// Columns(col_names << get values),  // if using associative array
	Columns(col_names),
	Source Label Column("Label"),
	Stacked Data Column("Data"),
	Output Table("stacktable")
);
-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: How do i Stack newly created column without specified naming

You are trying to use Associative Array as input for << Stack. You can get the values from associative array by using << Get Values. (thought un this case it might be better to use list).

Names Default To Here(1);

dt = New Table("",
	Add Rows(1),
	New Column("FINAL_RESULT", Character, Nominal, Values({"TEST1_TEST2_TEST3"}))
);

num_columns = 3;
col_names = {};

For(i = 1, i <= num_columns, i++,
	col_name = Char(400 + (i - 1) * 100);
	new_col = dt << New Column(col_name, Character, Nominal, formula(Word(i, :FINAL_RESULT, "_"), ""));
	Insert Into(col_names, new_col << get name);
);

stacktable = dt << Stack(
	// Columns(col_names << get values),  // if using associative array
	Columns(col_names),
	Source Label Column("Label"),
	Stacked Data Column("Data"),
	Output Table("stacktable")
);
-Jarmo
weilyne
Level I

Re: How do i Stack newly created column without specified naming

Thanks you and I am able to stack those column now.