cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
See how to use to use Text Explorer to glean valuable information from text data at April 25 webinar.
Choose Language Hide Translation Bar
View Original Published Thread

I need help to make this loop work

gallardet
Level III

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