cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Use World Cup data to build models, explore spatial relationships, and create informative visualizations in JMP. Register. July 17, 2 pm US Eastern Time.
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
tarkan_bih
Level III

Convert a list of strings into a column names

I am trying a to run a script that uses a regex to find column names and puts them in a list to then stack. I am struggling to get the actual stack part to work and I think it has to do with the list containing strings rather then column names. Is there a way to convert a list strings into column names?

 

ref = open(dir||datafile);

allColNames = ref << getcolumnnames;
edgeCols = {};

Ncols = N items(allColNames);
for(i = 1, i <= Ncols, i++,
	cname = Column(allColNames[i]) << get Name;
	if(!Is Missing (regex(cname,"EDGE\d+") ),
		insert into(edgeCols,cname);
	);
);


edge stack = ref << stack(
	columns(EdgeCols),
	Source Label Column("Label");
	Source Data Column("Data");
	Output Table("Stack");
);
1 ACCEPTED SOLUTION

Accepted Solutions
gzmorgan0
Super User (Alumni)

Re: Convert a list of strings into a column names

Your syntax for stack is incorrect:

  • there are semicolons where there should be commas
  • it is not Source Data Column but Stacked Data Column
edge stack = ref << stack(
	columns( edgeCols),
	Source Label Column("Label"),
	Stacked Data Column("Data"),
	Output Table("Stack")
);

View solution in original post

1 REPLY 1
gzmorgan0
Super User (Alumni)

Re: Convert a list of strings into a column names

Your syntax for stack is incorrect:

  • there are semicolons where there should be commas
  • it is not Source Data Column but Stacked Data Column
edge stack = ref << stack(
	columns( edgeCols),
	Source Label Column("Label"),
	Stacked Data Column("Data"),
	Output Table("Stack")
);

Recommended Articles