cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP 19 is here! See the new features at jmp.com/new.
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
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