Choose Language Hide Translation Bar
Highlighted
AndresGlez
Level III

Help for Fit Y by X using For Loop

Hi all, hope somebody can help me with this request, I am trying to write a JSL script to create multiple Analysis Fit Y to X using a where condition, then I need to save every analysis generated with the values of the column used for Where as JPEG file.

So far, this is my initial script but I noticed that I am just creating a repeated analysis (times the tools used for  "Where"), I guess my error is somewhere on how I specify the N items. I am adding also a sample table for the data.

Thank you in advance.

 

Names Default To Here( 1 );
dt = Current Data Table();
summarize(groupid = by(:TOOL));
show (groupid);

For( i = 1, i <= N Items( groupid ), i++,

pic = dt << Oneway(
Y( :Measure ),
X( :Processdate ),
Where ( :TOOL == groupid [i]);
pic << Save Picture( "E:\Sample\FitYbyX_" || groupid[i] ||".jpg", JPEG );
););

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Help for Fit Y by X using For Loop

I think it might be better to use :TOOL in the By role and then iterate over the results:

 

Names Default To Here( 1 );

dt = Current Data Table();

Summarize( groupid = by( :TOOL ) );
Show( groupid );

ow = dt << Oneway( Y( :Measure ), X( :Processdate ), By( :TOOL ) );
	
For( i = 1, i <= N Items( groupid ), i++,
	pic = ow[i] << Save Picture( "E:\Sample\FitYbyX_" || groupid[i] || ".jpg", JPEG )
);
Learn it once, use it forever!

View solution in original post

2 REPLIES 2
Highlighted

Re: Help for Fit Y by X using For Loop

I think it might be better to use :TOOL in the By role and then iterate over the results:

 

Names Default To Here( 1 );

dt = Current Data Table();

Summarize( groupid = by( :TOOL ) );
Show( groupid );

ow = dt << Oneway( Y( :Measure ), X( :Processdate ), By( :TOOL ) );
	
For( i = 1, i <= N Items( groupid ), i++,
	pic = ow[i] << Save Picture( "E:\Sample\FitYbyX_" || groupid[i] || ".jpg", JPEG )
);
Learn it once, use it forever!

View solution in original post

Highlighted
AndresGlez
Level III

Re: Help for Fit Y by X using For Loop

Thank you @markbailey  this is exactly what I need.

Article Labels

    There are no labels assigned to this post.