<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to use Term Values in a For Loop expressing a column name in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-use-Term-Values-in-a-For-Loop-expressing-a-column-name/m-p/460113#M70504</link>
    <description>&lt;P&gt;I'm trying to cycle through columns and set value to create table later.&amp;nbsp; However, "Term Value" will not allow ith substitution for each column (bolded below in the script) in the For Loop.&amp;nbsp; The script just spits out the default values.&amp;nbsp; What would be the correct format to assign a column in this For Loop?&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//Troubled Section//&lt;BR /&gt;		{Probability Paper(
			Profiler(
				1,
				Confidence Intervals( 1 ),
				Term Value( &lt;STRONG&gt;Startnam[i]&lt;/STRONG&gt;(Dur1[i] / 2, Show( 1 ))),
				Remember Settings( "Mid Life", Differences Report( 0 ) ),
				Term Value( &lt;STRONG&gt;"Start 103-0.03"&lt;/STRONG&gt;(Dur1[i], Show( 1 ))),
				Remember Settings( "Full Life", Differences Report( 1 ) ),
				Term Value( "Start 103-0.03"(Dur1[i], Show( 1 ))))
		)} &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2023 18:10:33 GMT</pubDate>
    <dc:creator>Timesawasten12</dc:creator>
    <dc:date>2023-06-09T18:10:33Z</dc:date>
    <item>
      <title>How to use Term Values in a For Loop expressing a column name</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-use-Term-Values-in-a-For-Loop-expressing-a-column-name/m-p/460113#M70504</link>
      <description>&lt;P&gt;I'm trying to cycle through columns and set value to create table later.&amp;nbsp; However, "Term Value" will not allow ith substitution for each column (bolded below in the script) in the For Loop.&amp;nbsp; The script just spits out the default values.&amp;nbsp; What would be the correct format to assign a column in this For Loop?&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//Troubled Section//&lt;BR /&gt;		{Probability Paper(
			Profiler(
				1,
				Confidence Intervals( 1 ),
				Term Value( &lt;STRONG&gt;Startnam[i]&lt;/STRONG&gt;(Dur1[i] / 2, Show( 1 ))),
				Remember Settings( "Mid Life", Differences Report( 0 ) ),
				Term Value( &lt;STRONG&gt;"Start 103-0.03"&lt;/STRONG&gt;(Dur1[i], Show( 1 ))),
				Remember Settings( "Full Life", Differences Report( 1 ) ),
				Term Value( "Start 103-0.03"(Dur1[i], Show( 1 ))))
		)} &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 18:10:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-use-Term-Values-in-a-For-Loop-expressing-a-column-name/m-p/460113#M70504</guid>
      <dc:creator>Timesawasten12</dc:creator>
      <dc:date>2023-06-09T18:10:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Term Values in a For Loop expressing a column name</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-use-Term-Values-in-a-For-Loop-expressing-a-column-name/m-p/464533#M70902</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/36888"&gt;@Timesawasten12&lt;/a&gt; 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 &lt;FONT face="helvetica"&gt;Fitness&lt;/FONT&gt; sample data to run the analysis against, and the attached table &lt;FONT face="helvetica"&gt;Settings&lt;/FONT&gt; for the setting values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;	tblRef = Open("$Sample_Data/Fitness.JMP");
	settingsTblRef = Data Table("Settings");
	profilerExpr = Expr(Profiler(1,Confidence Intervals(1)));

	For(i=1,i&amp;lt;=N Row(settingsTblRef),i++,
		nextTermValExpr = Expr(Term Value());
		For(j=1,j&amp;lt;=N Cols(settingsTblRef),j++,
			nextCol = Substitute(
				Expr(colName(val,Lock(0),Show(1))),
				Expr(colName),Parse(Column(settingsTblRef,j)&amp;lt;&amp;lt;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 &amp;lt;&amp;lt; Fit Model(
				Y( :Oxy ),
				Effects( :Runtime, :Weight, :RunPulse, :RstPulse, :MaxPulse ),
				Personality( "Standard Least Squares" ),
				Emphasis( "Effect Leverage" ),
				Run(pExpr)
			)
		),
		Expr(pExpr),Name Expr(profilerExpr)
	));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For each row of setting values, loop over each column building the individual column expressions inside &lt;FONT face="courier new,courier"&gt;Term Value&lt;/FONT&gt;. 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 &lt;FONT face="courier new,courier"&gt;Name Expr&lt;/FONT&gt; so its unevaluated contents are used. For example, the first &lt;FONT face="courier new,courier"&gt;Substitute&lt;/FONT&gt; replaces &lt;FONT face="courier new,courier"&gt;colName&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;val&lt;/FONT&gt; in the first argument with the parsed name of the column and the value from the &lt;FONT face="helvetica"&gt;Settings&lt;/FONT&gt; table, respectively. &lt;FONT face="courier new,courier"&gt;Name Expr&lt;/FONT&gt; is needed in &lt;FONT face="courier new,courier"&gt;Insert Into&lt;/FONT&gt; to keep the expression &lt;FONT face="courier new,courier"&gt;nextCol&lt;/FONT&gt; from evaluating any further than what &lt;FONT face="courier new,courier"&gt;Substitute&lt;/FONT&gt; provides it. Same goes for the other &lt;FONT face="courier new,courier"&gt;Name Expr&lt;/FONT&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Feb 2022 22:49:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-use-Term-Values-in-a-For-Loop-expressing-a-column-name/m-p/464533#M70902</guid>
      <dc:creator>DonMcCormack</dc:creator>
      <dc:date>2022-02-25T22:49:42Z</dc:date>
    </item>
  </channel>
</rss>

