cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar

How to use Term Values in a For Loop expressing a column name

I'm trying to cycle through columns and set value to create table later.  However, "Term Value" will not allow ith substitution for each column (bolded below in the script) in the For Loop.  The script just spits out the default values.  What would be the correct format to assign a column in this For Loop?

Thanks 

 

//Troubled Section//
{Probability Paper( Profiler( 1, Confidence Intervals( 1 ), Term Value( Startnam[i](Dur1[i] / 2, Show( 1 ))), Remember Settings( "Mid Life", Differences Report( 0 ) ), Term Value( "Start 103-0.03"(Dur1[i], Show( 1 ))), Remember Settings( "Full Life", Differences Report( 1 ) ), Term Value( "Start 103-0.03"(Dur1[i], Show( 1 )))) )}


 

1 REPLY 1

Re: How to use Term Values in a For Loop expressing a column name

@Timesawasten12 I don't know how you'll be accessing the column names and values, but the following example (or some variation of it) might work. I'm using the Fitness sample data to run the analysis against, and the attached table Settings for the setting values.

	tblRef = Open("$Sample_Data/Fitness.JMP");
	settingsTblRef = Data Table("Settings");
	profilerExpr = Expr(Profiler(1,Confidence Intervals(1)));

	For(i=1,i<=N Row(settingsTblRef),i++,
		nextTermValExpr = Expr(Term Value());
		For(j=1,j<=N Cols(settingsTblRef),j++,
			nextCol = Substitute(
				Expr(colName(val,Lock(0),Show(1))),
				Expr(colName),Parse(Column(settingsTblRef,j)<<Get Name),
				Expr(val),Column(settingsTblRef,j)[i]
			);
			Insert Into(nextTermValExpr,Name Expr(nextCol))
		);
		Insert Into(profilerExpr,Name Expr(nextTermValExpr));
		nextSettingName = Substitute(
			Expr(Remember Settings(nextName, Differences Report( 0 ) )),
			Expr(nextName),"Setting " || Char(i)
		);
		Insert Into(profilerExpr,Name Expr(nextSettingName))
	);

	Eval(Substitute(
		Expr(
			fitModelPlt = tblRef << Fit Model(
				Y( :Oxy ),
				Effects( :Runtime, :Weight, :RunPulse, :RstPulse, :MaxPulse ),
				Personality( "Standard Least Squares" ),
				Emphasis( "Effect Leverage" ),
				Run(pExpr)
			)
		),
		Expr(pExpr),Name Expr(profilerExpr)
	));

For each row of setting values, loop over each column building the individual column expressions inside Term Value. At the bottom of the loop insert the setting name. When this is done, insert the finished expression in the main analysis expression and evaluate it. The trick is using Name Expr so its unevaluated contents are used. For example, the first Substitute replaces colName and val in the first argument with the parsed name of the column and the value from the Settings table, respectively. Name Expr is needed in Insert Into to keep the expression nextCol from evaluating any further than what Substitute provides it. Same goes for the other Name Expr.