BookmarkSubscribeRSS Feed
axcelenator1

Occasional Contributor

Joined:

Sep 3, 2018

Problem with grouping columns

Hello, I have some JSL code which includes double loop and a the end of the code includes a line which i want to group the columns but it doesn't do that. 

 

1. How can I fix the code?

2. When running the script is any way that the new table opens will be another one and not the original table? I mean I want another file will be opened..

The code and table are attached:

dt = open("C:\JMPCommunity\DataTableExample.jmp");

s_list = {sen1, sen2, sen3, sen4, sen5};
test_list ={test1, test2, test3};
tokens_list={Col1, Col2, Col3};
g_list={g1,g2,g3};

For(j = 1, j<=Length(test_list), j++,
	For( i = 1, i<= Length(s_list), i++, 
	    dt << New Column  ( test_list[j] ||"_" || s_list[i],  
		Numeric,
		Continuous,
		Formula(
				Num(Word( i, As Column(Column(tokens_list[j] )), "|" ))
			    )
		)
				
	);
	g_list[j] = dt << Group Columns(":" || test_list[j]|| "_" || s_list[1], Length(s_list))
);




1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
axcelenator1

Occasional Contributor

Joined:

Sep 3, 2018

Solution

Re: Problem with grouping columns

I found the problem: The problem is that I've tried to concatenate a "string" with an : operator. This is not possible. The way to do it is:

g_list[j] = dt << Group Columns(:(test_list[j] || "_" || s_list[1]), Length(s_list));
1 REPLY
Highlighted
axcelenator1

Occasional Contributor

Joined:

Sep 3, 2018

Solution

Re: Problem with grouping columns

I found the problem: The problem is that I've tried to concatenate a "string" with an : operator. This is not possible. The way to do it is:

g_list[j] = dt << Group Columns(:(test_list[j] || "_" || s_list[1]), Length(s_list));