cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Graph Builder Toolbar streamlines interactive graphing. Creates shortcuts on Report and GraphBuilder Helpers toolbars. Download and install the extension.
  • JMP will suspend normal business operations for our Rest and Recharge Day on Friday, October 2, 2026.
    Regular business hours will resume on Monday, October 5, 2026.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
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

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 )
);

View solution in original post

2 REPLIES 2

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 )
);
AndresGlez
Level III

Re: Help for Fit Y by X using For Loop

Thank you @Mark_Bailey  this is exactly what I need.

Recommended Articles