cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
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.