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
Heart_To_Tell
Level II

Creating Fit Group Bivariate Charts with For Loop

Instead of using hardcoded column names as input, I'd like a simple for loop to create the same charts as without the for loop.

 

dt = Open("C:\Program Files\SAS\JMP\15\Samples\Data\semiconductor capability.jmp");
Y_parameters = {"NPN1", "NPN2", "NPN3"};
X_parameters = {"PNP1", "PNP2", "PNP3"};

Fit Group(
	//For i:
		//For j:
			Bivariate( Y( As Column(dt, Y_parameters[i]) ), X( As Column(dt, X_parameters[j])) ),
		//end For j:
	//end For i
	
	//Want to replace the hard coded Y and X parameters with above for loop
	Bivariate( Y( :NPN1 ), X( :PNP1 ) ),
	Bivariate( Y( :NPN1 ), X( :PNP2 ) ),
	Bivariate( Y( :NPN1 ), X( :PNP3 ) ),
	Bivariate( Y( :NPN2 ), X( :PNP1 ) ),
	Bivariate( Y( :NPN2 ), X( :PNP2 ) ),
	Bivariate( Y( :NPN2 ), X( :PNP3 ) ),
	Bivariate( Y( :NPN3 ), X( :PNP1 ) ),
	Bivariate( Y( :NPN3 ), X( :PNP2 ) ),
	Bivariate( Y( :NPN3 ), X( :PNP3 ) ),
	<<{Arrange in Rows( 3 )}
);
1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Creating Fit Group Bivariate Charts with For Loop

I would most likely do it with two lists (or associative array) and then looping. I think I wouldn't even use Fit Group unless I really had to and just create them with display boxes.

You can also try to use expressions, but this gets messy and complicated quickly (and at least this solution isn't as robust as I would like to use, I just tried different things and got it working):

 

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");
Y_parameters = {"NPN1", "NPN2", "NPN3"};
X_parameters = {"PNP1", "PNP2", "PNP3"};

fg_expr = Expr(
	dt << Fit Group(test, <<{Arrange in Rows(3)})
);

biv_expr = Expr({});

For(i = 1, i <= N Items(Y_parameters),i++,
	next_biv = Eval Expr(Bivariate(Y(Column(Expr(Y_parameters[i]))), X(Column(Expr(X_parameters[i])))));
	Insert Into(biv_expr, Name Expr(next_biv));
);

Substitute Into(fg_expr, Expr(test), Expr(EvalList(NameExpr(biv_expr))));
Show(Name Expr(fg_expr));
fg_expr;

 

-Jarmo

View solution in original post

4 REPLIES 4
jthi
Super User

Re: Creating Fit Group Bivariate Charts with For Loop

If you want to get all combinations, I think you can just use

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");
Y_parameters = {"NPN1", "NPN2", "NPN3"};
X_parameters = {"PNP1", "PNP2", "PNP3"};

Fit Group(
	Bivariate( Y(Eval(Y_parameters)), X(Eval(x_parameters))),
	<<{Arrange in Rows( 3 )}
);

jthi_0-1639597764201.png

 

-Jarmo
Heart_To_Tell
Level II

Re: Creating Fit Group Bivariate Charts with For Loop

Thanks for the suggestion as always.

Do you have a suggestion for just getting charts for certain pairs. Such as NPN1 vs PNP1 and NPN2 vs PNP2?
jthi
Super User

Re: Creating Fit Group Bivariate Charts with For Loop

I would most likely do it with two lists (or associative array) and then looping. I think I wouldn't even use Fit Group unless I really had to and just create them with display boxes.

You can also try to use expressions, but this gets messy and complicated quickly (and at least this solution isn't as robust as I would like to use, I just tried different things and got it working):

 

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");
Y_parameters = {"NPN1", "NPN2", "NPN3"};
X_parameters = {"PNP1", "PNP2", "PNP3"};

fg_expr = Expr(
	dt << Fit Group(test, <<{Arrange in Rows(3)})
);

biv_expr = Expr({});

For(i = 1, i <= N Items(Y_parameters),i++,
	next_biv = Eval Expr(Bivariate(Y(Column(Expr(Y_parameters[i]))), X(Column(Expr(X_parameters[i])))));
	Insert Into(biv_expr, Name Expr(next_biv));
);

Substitute Into(fg_expr, Expr(test), Expr(EvalList(NameExpr(biv_expr))));
Show(Name Expr(fg_expr));
fg_expr;

 

-Jarmo
Heart_To_Tell
Level II

Re: Creating Fit Group Bivariate Charts with For Loop

Thank you Jarmo! Works as expected!