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
gallardet
Level III

I need help to make this loop work

Hello everybody.

Names Default To Here( 1 );
dt = Current Data Table();
For ( i = 1951, i <= 2021, i++, 


	gb = dt << Bivariate(
		Y( :PRCPC ),
		X( :Mes ),
		Fit Each Value( {Line Color( {208, 64, 86} )} ),
		Fit Line( {Line Color( {45, 177, 53} )} ),
		Fit Spline( 20.13724, {Line Color( {64, 110, 211} )} ),
		Where( :Any == [i]),
		SendToReport(
			Dispatch( {}, "Bivar Plot", FrameBox, {Frame Size( 486, 411 )} ),
			Dispatch( {}, "Linear Fit", "Summary of Fit",OutlineBox, {Close( 1 )} )
		),

	);
	gb << Save Picture( "/Users/mgc/Desktop/" || :Any == [i] || ".png", PNG );
	
),

. Thank you in advance

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: I need help to make this loop work

In your Where() clause, you need to remove the {} around the "i" variable.

In the Save Picture, you need to convert the value of "i" to a character before it can be concatenated to the string.

Names Default To Here( 1 );
dt = Current Data Table();
For ( i = 1951, i <= 2021, i++, 


	gb = dt << Bivariate(
		Y( :PRCPC ),
		X( :Mes ),
		Fit Each Value( {Line Color( {208, 64, 86} )} ),
		Fit Line( {Line Color( {45, 177, 53} )} ),
		Fit Spline( 20.13724, {Line Color( {64, 110, 211} )} ),
		Where( :Any == i),
		SendToReport(
			Dispatch( {}, "Bivar Plot", FrameBox, {Frame Size( 486, 411 )} ),
			Dispatch( {}, "Linear Fit", "Summary of Fit",OutlineBox, {Close( 1 )} )
		),

	);
	gb << Save Picture( "/Users/mgc/Desktop/" || char(i) || ".png", PNG );
	
);
Jim

View solution in original post

1 REPLY 1
txnelson
Super User

Re: I need help to make this loop work

In your Where() clause, you need to remove the {} around the "i" variable.

In the Save Picture, you need to convert the value of "i" to a character before it can be concatenated to the string.

Names Default To Here( 1 );
dt = Current Data Table();
For ( i = 1951, i <= 2021, i++, 


	gb = dt << Bivariate(
		Y( :PRCPC ),
		X( :Mes ),
		Fit Each Value( {Line Color( {208, 64, 86} )} ),
		Fit Line( {Line Color( {45, 177, 53} )} ),
		Fit Spline( 20.13724, {Line Color( {64, 110, 211} )} ),
		Where( :Any == i),
		SendToReport(
			Dispatch( {}, "Bivar Plot", FrameBox, {Frame Size( 486, 411 )} ),
			Dispatch( {}, "Linear Fit", "Summary of Fit",OutlineBox, {Close( 1 )} )
		),

	);
	gb << Save Picture( "/Users/mgc/Desktop/" || char(i) || ".png", PNG );
	
);
Jim