cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Due to the recently reported Microsoft outage, users may be temporarily unable to access My JMP or experience a delay receiving their verification codes. If you have previously installed JMP on your computer, this outage should not impact your ability to access the software. My JMP services will be restored as soon as Microsoft resolves this issue.
  • Image to Table JMP extension imports single or batch images as data tables. Useful to extract curves from pictures or convert image data to curve data to use in analyses like Functional Data Explorer. Download and install the extension.

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