<?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 Re: I need to populate a new column based on results of an if/then statement in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/I-need-to-populate-a-new-column-based-on-results-of-an-if-then/m-p/675985#M86275</link>
    <description>&lt;P&gt;Thank you Jim.&amp;nbsp; I've meant to circle back shortly after your reply but have been trying to dubug the code.&amp;nbsp; I have not gotten it to work for some reason.&amp;nbsp; I used the debugger and got this message:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="learning_JSL_0-1694202790574.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/56418i75EAD0096AAD4234/image-size/medium?v=v2&amp;amp;px=400" role="button" title="learning_JSL_0-1694202790574.png" alt="learning_JSL_0-1694202790574.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just wanted you to know I received your input - I will keep trying.&amp;nbsp; Thanks.&lt;/P&gt;</description>
    <pubDate>Fri, 08 Sep 2023 19:54:02 GMT</pubDate>
    <dc:creator>learning_JSL</dc:creator>
    <dc:date>2023-09-08T19:54:02Z</dc:date>
    <item>
      <title>I need to populate a new column based on results of an if/then statement</title>
      <link>https://community.jmp.com/t5/Discussions/I-need-to-populate-a-new-column-based-on-results-of-an-if-then/m-p/674610#M86185</link>
      <description>&lt;P&gt;Hi - I am trying to create and populate a group of new columns based on results of an if/then statement.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;STEP 1:&lt;/P&gt;&lt;P&gt;I need to create the new empty columns that will be populated.&amp;nbsp; (55 in all)&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Each new column is a numeric, continuous field.)&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The name of each column will correspond to the name of each of the 55 compounds in the group followed by "_ppt".&amp;nbsp; E.g. the compound named "4:2 FTS" results in a new column named [4:2 FTS_ppt].&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;STEP 2:&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Row by row, I would populate the new columns using an if/then statement that evaluates three existing columns associated with each of the 55 compounds in the group.&amp;nbsp; &amp;nbsp;Specifically,&lt;/P&gt;&lt;P&gt;if&amp;nbsp; [RES_VALUE_4:2 FTS] &amp;gt;=&amp;nbsp; [RL_4:2 FTS]&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;THEN&amp;nbsp; &amp;nbsp; &amp;nbsp; [4:2 FTS_ppt] = [RES_VALUE_4:2 FTS]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if&amp;nbsp;[RES_VALUE_4:2 FTS] &amp;lt;&amp;nbsp; [RL_4:2 FTS]&amp;nbsp; &amp;nbsp; &amp;nbsp;AND&amp;nbsp; &amp;nbsp;&amp;nbsp; DETECT_FLAG_4:2 FTS] = N&amp;nbsp; &amp;nbsp; &amp;nbsp; AND&amp;nbsp; &amp;nbsp; [RL_4:2 FTS] &amp;lt;= 3&amp;nbsp; &amp;nbsp; THEN&amp;nbsp; [4:2 FTS_ppt] = 0.0009.&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if&amp;nbsp;[RES_VALUE_4:2 FTS] &amp;lt;&amp;nbsp; [RL_4:2 FTS]&amp;nbsp; &amp;nbsp; &amp;nbsp;AND&amp;nbsp; &amp;nbsp;&amp;nbsp; DETECT_FLAG_4:2 FTS] = N&amp;nbsp; &amp;nbsp; &amp;nbsp; AND&amp;nbsp; &amp;nbsp; [RL_4:2 FTS] &amp;gt; 3&amp;nbsp; &amp;nbsp; THEN&amp;nbsp; [4:2 FTS_ppt] = NULL.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here are the existing column names with a suffix that is the compound name.&amp;nbsp; I am using JMP Pro 17.0.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="learning_JSL_1-1693949204065.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/56244i92BD60824805B949/image-size/medium?v=v2&amp;amp;px=400" role="button" title="learning_JSL_1-1693949204065.png" alt="learning_JSL_1-1693949204065.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="learning_JSL_2-1693949229746.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/56246i43C293D1C432DC41/image-size/medium?v=v2&amp;amp;px=400" role="button" title="learning_JSL_2-1693949229746.png" alt="learning_JSL_2-1693949229746.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="learning_JSL_3-1693949262413.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/56247i231F191594BB6DEC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="learning_JSL_3-1693949262413.png" alt="learning_JSL_3-1693949262413.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any guidance would be most appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2023 21:29:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/I-need-to-populate-a-new-column-based-on-results-of-an-if-then/m-p/674610#M86185</guid>
      <dc:creator>learning_JSL</dc:creator>
      <dc:date>2023-09-05T21:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: I need to populate a new column based on results of an if/then statement</title>
      <link>https://community.jmp.com/t5/Discussions/I-need-to-populate-a-new-column-based-on-results-of-an-if-then/m-p/674651#M86190</link>
      <description>&lt;OL&gt;
&lt;LI&gt;The purpose of the Discussion Community is not to be a source for JMP users to get scripts written at their request.&amp;nbsp; It is there to assist users in learning JMP.&lt;/LI&gt;
&lt;LI&gt;Given the pseudo code you provided, it is clear that you need to take the time to read the JMP Scripting Guide.&amp;nbsp; It is available in the JMP Documentation Library under the Help pull down menu in JMP.&lt;/LI&gt;
&lt;LI&gt;Below is an attempt to help you with your issue.&amp;nbsp; It is not tested, since I do not have any of your data.&amp;nbsp; Please take the time to study and learn the code.&amp;nbsp; The functions are well documented in the Scripting Index, and in the JSL Scripting Reference.
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
groupList = {"RES_VALUE", "RES_TEXT", "DETECT_FLAG", "RL", "DILUTION_FACTOR"};

dt = Current Data Table();

// Find all of the different compounds.  This is done by using the "RES_VALUE" columns
// and stripping off the compound names from each of them
compList = {};
For( i = 1, i &amp;lt;= N Cols( dt ), i++,
	colName = Column( dt, i ) &amp;lt;&amp;lt; get name;
	If( Contains( colName, "RES_VALUE" ) == 1,
		Insert Into( compList, Substr( colName, 11 ) )
	);
);

// Create the columns
For Each( {comp, i}, compList,
	Eval(
		Parse(
			"dt &amp;lt;&amp;lt; New Column( \!"" || compList[i] || "_ppt" || "\!",
						numeric,
						continuous,
						formula(
							If( :\!"RES_VALUE "
			 || comp || "\!"n &amp;gt;= :\!"RL " || comp || "\!"n,
								x = :\!"RES_VALUE " || comp ||
			"\!"n
							);
							If(
								:\!"RES_VALUE " || comp ||
			"\!"n &amp;lt; :\!"RL " || comp || "\!"n &amp;amp; :\!"DETECT_FLAG " || comp || "\!"n == \!"N\!" &amp;amp;
								:\!"RL " || comp ||
			"\!"n &amp;lt;= 3,
								x = 0.0009
							);
							If(
								:\!"RES_VALUE "
			 || comp || "\!"n &amp;lt; :\!"RL " || comp || "\!"n &amp;amp; :\!"DETECT_FLAG " || comp || "\!"n == \!"N\!" &amp;amp;
								:\!"RL "
			 || comp || "\!"n &amp;gt; 3,
								x = .
							);
							x;
						)
					);"
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Wed, 06 Sep 2023 02:58:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/I-need-to-populate-a-new-column-based-on-results-of-an-if-then/m-p/674651#M86190</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2023-09-06T02:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: I need to populate a new column based on results of an if/then statement</title>
      <link>https://community.jmp.com/t5/Discussions/I-need-to-populate-a-new-column-based-on-results-of-an-if-then/m-p/674835#M86200</link>
      <description>&lt;P&gt;Thanks Jim.&amp;nbsp; Yes, point well taken.&amp;nbsp; I need to spend more time in the foundations of jsl before jumping into my work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code above created all of the columns correctly but the formula is producing only null values (".").&amp;nbsp; I haven't been able to troubleshoot the error but will keep trying.&amp;nbsp; Thanks again.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2023 15:24:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/I-need-to-populate-a-new-column-based-on-results-of-an-if-then/m-p/674835#M86200</guid>
      <dc:creator>learning_JSL</dc:creator>
      <dc:date>2023-09-06T15:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: I need to populate a new column based on results of an if/then statement</title>
      <link>https://community.jmp.com/t5/Discussions/I-need-to-populate-a-new-column-based-on-results-of-an-if-then/m-p/674876#M86202</link>
      <description>&lt;P&gt;I will take a look at it if you can supply some sample data.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2023 15:55:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/I-need-to-populate-a-new-column-based-on-results-of-an-if-then/m-p/674876#M86202</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2023-09-06T15:55:12Z</dc:date>
    </item>
    <item>
      <title>Re: I need to populate a new column based on results of an if/then statement</title>
      <link>https://community.jmp.com/t5/Discussions/I-need-to-populate-a-new-column-based-on-results-of-an-if-then/m-p/674895#M86203</link>
      <description>&lt;P&gt;Thanks Jim.&amp;nbsp; I attached&amp;nbsp;the jmp table below that contains a small subset of rows from my dataset.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2023 16:17:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/I-need-to-populate-a-new-column-based-on-results-of-an-if-then/m-p/674895#M86203</guid>
      <dc:creator>learning_JSL</dc:creator>
      <dc:date>2023-09-06T16:17:32Z</dc:date>
    </item>
    <item>
      <title>Re: I need to populate a new column based on results of an if/then statement</title>
      <link>https://community.jmp.com/t5/Discussions/I-need-to-populate-a-new-column-based-on-results-of-an-if-then/m-p/674979#M86204</link>
      <description>&lt;P&gt;Two things needed to be changed.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The value of the variable x that is used in the formula needs to be initialized for each rows execution.&lt;/LI&gt;
&lt;LI&gt;The formula execution need to be UNsuppressed.&lt;/LI&gt;
&lt;/OL&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
groupList = {"RES_VALUE", "RES_TEXT", "DETECT_FLAG", "RL", "DILUTION_FACTOR"};

dt = Current Data Table();

// Find all of the different compounds.  This is done by using the "RES_VALUE" columns
// and stripping off the compound names from each of them
compList = {};
For( i = 1, i &amp;lt;= N Cols( dt ), i++,
	colName = Column( dt, i ) &amp;lt;&amp;lt; get name;
	If( Contains( colName, "RES_VALUE" ) == 1,
		Insert Into( compList, Substr( colName, 11 ) )
	);
);

// Create the columns
For Each( {comp, i}, compList,
	Eval(
		Parse(
			"dt &amp;lt;&amp;lt; New Column( \!"" || compList[i] || "_ppt" ||
			"\!",
						numeric,
						continuous, formula(
						    x=.;
							If( :\!"RES_VALUE "
			 || comp || "\!"n &amp;gt;= :\!"RL " || comp || "\!"n,
								x = :\!"RES_VALUE " || comp ||
			"\!"n
							);
							If(
								:\!"RES_VALUE " ||
			comp || "\!"n &amp;lt; :\!"RL " || comp || "\!"n &amp;amp; :\!"DETECT_FLAG " || comp || "\!"n == \!"N\!" &amp;amp;
								:\!"RL "
			 || comp || "\!"n &amp;lt;= 3,
								x = 0.0009
							);
							If(
								:\!"RES_VALUE "
			 || comp || "\!"n &amp;lt; :\!"RL " || comp || "\!"n &amp;amp; :\!"DETECT_FLAG " || comp || "\!"n == \!"N\!" &amp;amp;
								:\!"RL "
			 || comp || "\!"n &amp;gt; 3,
								x = .
							);
							x;
						)
					);"
		)
	)
);
dt &amp;lt;&amp;lt; Suppress Formula Eval( 0 );
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Sep 2023 18:27:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/I-need-to-populate-a-new-column-based-on-results-of-an-if-then/m-p/674979#M86204</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2023-09-06T18:27:43Z</dc:date>
    </item>
    <item>
      <title>Re: I need to populate a new column based on results of an if/then statement</title>
      <link>https://community.jmp.com/t5/Discussions/I-need-to-populate-a-new-column-based-on-results-of-an-if-then/m-p/675985#M86275</link>
      <description>&lt;P&gt;Thank you Jim.&amp;nbsp; I've meant to circle back shortly after your reply but have been trying to dubug the code.&amp;nbsp; I have not gotten it to work for some reason.&amp;nbsp; I used the debugger and got this message:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="learning_JSL_0-1694202790574.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/56418i75EAD0096AAD4234/image-size/medium?v=v2&amp;amp;px=400" role="button" title="learning_JSL_0-1694202790574.png" alt="learning_JSL_0-1694202790574.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just wanted you to know I received your input - I will keep trying.&amp;nbsp; Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2023 19:54:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/I-need-to-populate-a-new-column-based-on-results-of-an-if-then/m-p/675985#M86275</guid>
      <dc:creator>learning_JSL</dc:creator>
      <dc:date>2023-09-08T19:54:02Z</dc:date>
    </item>
    <item>
      <title>Re: I need to populate a new column based on results of an if/then statement</title>
      <link>https://community.jmp.com/t5/Discussions/I-need-to-populate-a-new-column-based-on-results-of-an-if-then/m-p/675987#M86276</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="learning_JSL_1-1694202910732.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/56419i5DEABB53B12EF742/image-size/medium?v=v2&amp;amp;px=400" role="button" title="learning_JSL_1-1694202910732.png" alt="learning_JSL_1-1694202910732.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2023 19:55:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/I-need-to-populate-a-new-column-based-on-results-of-an-if-then/m-p/675987#M86276</guid>
      <dc:creator>learning_JSL</dc:creator>
      <dc:date>2023-09-08T19:55:22Z</dc:date>
    </item>
    <item>
      <title>Re: I need to populate a new column based on results of an if/then statement</title>
      <link>https://community.jmp.com/t5/Discussions/I-need-to-populate-a-new-column-based-on-results-of-an-if-then/m-p/676002#M86278</link>
      <description>&lt;P&gt;Yes!&amp;nbsp; &amp;nbsp;I just got it to work.&amp;nbsp; Thanks again for your help on this!&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2023 20:19:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/I-need-to-populate-a-new-column-based-on-results-of-an-if-then/m-p/676002#M86278</guid>
      <dc:creator>learning_JSL</dc:creator>
      <dc:date>2023-09-08T20:19:02Z</dc:date>
    </item>
  </channel>
</rss>

