cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Instantly extract effect sizes, F-ratios, and FDR-adjusted p-values from your models with the Calculate Effects Sizes extension, available now in the JMP Marketplace!
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
SpannerHead
Level VI

Forming a Column Formula from an Associative Array

I looked but couldn't find a clear example.  I have a script that creates an associative array between pairs of columns in a table.  I now want to leverage that array to create a formula referencing both the value and the key.  How is this done?

 

For( i = 1, i <= N Items( SpecCols ), i++,
    key = Column( dt, SpecCols[i] ); 
    value = Column( dt, Char(SpecCols[i])||" Pass/Fail");
    assocArray[key] = value;
			dt << New Column( (Column( dt, SpecCols[i] ) << get name) || " Best",
				Set Property( "Notes", Notes ),
				Set Property( "Limits", Limits ),
				Formula(If(
	:RETEST == Col Minimum(
		If(
			Col Mean( value, :LOT, :WAFER, :RETEST ) ==
			Eval( Parse( value)),
			:RETEST
		),
		:LOT,
		:WAFER,
		:SiteY,
		:SiteX
	),
	Eval( Parse(key))
))
);
);

 

 

 


Slán



SpannerHead
1 REPLY 1
jthi
Super User

Re: Forming a Column Formula from an Associative Array

Expression evaluation and in cases like this I like using Eval(Substitute())

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");

aa = Associative Array();
aa["NPN1"] = "NPN2";
aa["PNP1"] = "PNP2";
aa["INM1"] = "INM2";

new_cols = {};
For Each({{key, val}}, aa,
	new_col = Eval(Substitute(
		Expr(dt << New Column(key ||" "|| val, Numeric, Continuous, Formula(
			_term1_ + _term2_
		))),
		Expr(_term1_), Name Expr(AsColumn(dt, key)),
		Expr(_term2_), Name Expr(AsColumn(dt, val))
	));
	Insert Into(new_cols, (new_col << get name))
);

dt << Move Selected Columns(new_cols, To First);
-Jarmo

Recommended Articles