I am trying to transpose a table with a known Label column name, but Transpose column names that are only known at runtime. I have been trying for hours to figure out how to do this, but the task is greatly complicated by JSL mistaking the Transpose command for the matrix Transpose function and he Columns() argument to it for the function that gets the names of all columns in the table. In the following code, the list columns is populated with the names of the columns I want to transpose.
//Create the transpose expression
transposeExpr = Expr(Transpose(Columns(), Label(:Wt or Rd)));
//Pull the Columns argument expression out of it (this keeps me from having to create it myself and have it mistaken for the Columns() function)
columnsExpr = Arg(transposeExpr, 1);
For(i = 1, i <= numColumns, i++,
Insert Into(columnsExpr, Name Expr(As Column(colNames)));
);
Remove From(transposeExpr, 1);
Insert Into(transposeExpr, Name Expr(columnsExpr), 1);
cdt = Current Data Table();
cdt << Transpose(Name Expr(columnsExpr), Label(:Wt or Rd));
However, this still doesn't appear to work because columnsExpr still evaluates to a list of names of all the columns in the current table, rather than the Columns argument with actual references to the table. (I think it interprets these references are arguments to Columns the function)
Can anyone please explain what I am doing wrong?