I would like to automate creating multiple stacked tables from one original data table. I plan on doing this by creating a list of keywords, and if any column in my original table contains that keyword then it would be stacked in a new data table. Essentially I have a list of 3 keywords, so I would be creating 3 stacked data tables. My script has a nested for loop to iterate through all the columns in the original data table and see if they contain the keyword being indexed. See below:
groupNames = {"abc", "def", "ghi"};
for (i = 1, i <= nitems(groupNames), i++,
for (j = 1, j <= ncols(Data Table("Original Data")), j++,
if ((contains(Column Name(j), groupNames[i])),
Insert Into(tempStack, Column Name(j));
);
);
tempTable = Stack(
Columns(tempStack),
Source Label Column("Label"),
Stacked Data Column("Data"),
"Non-stacked columns"n (Keep(:tst_temp, :stdf_file)),
);
tempStack = {};
tempTable << set name(char(groupNames[i]) || " Stacked");
);
The problem that arises when executing this code is that the first group gets stacked just fine, but when the for loop indexes to i=2 to look for the next group it fails to look at the original data table and instead looks at the table that was just stacked (Data table "abc Stacked" in this case).
How can I make it so that my for loop looks at my original data table instead of the newly created table. Thanks!
Best,
kaoticllama