<?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: Saving Variables to New Tables and New Columns in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Saving-Variables-to-New-Tables-and-New-Columns/m-p/424954#M67416</link>
    <description>&lt;P&gt;Thank you for taking the time to explain the issue.&amp;nbsp; Im very new to JSL scripting and I appreciate you taking the time to examine how a new column can be a complex formula.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 08 Oct 2021 23:10:27 GMT</pubDate>
    <dc:creator>SMW</dc:creator>
    <dc:date>2021-10-08T23:10:27Z</dc:date>
    <item>
      <title>Saving Variables to New Tables and New Columns</title>
      <link>https://community.jmp.com/t5/Discussions/Saving-Variables-to-New-Tables-and-New-Columns/m-p/424075#M67330</link>
      <description>&lt;P&gt;I wrote a script that finds rows where col2 and col3 match specific strings and then returns the value of the cell in col7 of those rows.&amp;nbsp; However, I am having problems writing these variables to New Columns in New Tables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;....
New Table( "Results",Add Rows( 2 ),  
  New Column( " FUS",Character,"Nominal",  
    Set Values({"Fus1","Fus2"})),  
  New Column( "PASS/FAIL",continuous,"Nominal", formula( Name Expr(APass)),formula(Name Expr(BPass)));  
 )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Here, APass and Bpass are variables that equal the column7 value from respective search rows.&amp;nbsp; They are strings Pass and Fail respectively.&amp;nbsp; However, when I create the table the last function overides and fills in its results across the entire table. So the table should be Fus1-Pass Fus2-Fail, but outputs Fus1-Fail Fus2-Fail.&amp;nbsp; The reverse when I change the order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help on how to populate a new column with multiple variables ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Much Appreciated&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 19:58:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Saving-Variables-to-New-Tables-and-New-Columns/m-p/424075#M67330</guid>
      <dc:creator>SMW</dc:creator>
      <dc:date>2023-06-09T19:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: Saving Variables to New Tables and New Columns</title>
      <link>https://community.jmp.com/t5/Discussions/Saving-Variables-to-New-Tables-and-New-Columns/m-p/424114#M67332</link>
      <description>&lt;P&gt;As stated in your previous discussion on this topic, You CANNOT have to formulas defined for a column.&amp;nbsp; Here is a simple illustration of that using the Big Class data table.&amp;nbsp; If you define 2 formulas for a column, the second formula will replace the first formula.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;new column("two formula", formula(:height), formula(:weight));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Gives the following results&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1633555961399.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/36378iCDC9DBE5E35963D4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_0-1633555961399.png" alt="txnelson_0-1633555961399.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Note that the second formula defined is the one JMP ends up using.&lt;/P&gt;
&lt;P&gt;Now, this is not saying that a formula can not be complex.&amp;nbsp; One can actually define a formula that treats each row differently.&amp;nbsp; It just has to be defined in one formula.&amp;nbsp; Here is a simple example of a more complex formula that takes multiple columns into the formula, and makes comparisons between them.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt; New Column( "combined formula",
	formula(
		If(
			:Sex == "F" &amp;amp; :age &amp;gt; 12, :weight,
			:Sex == "F" &amp;amp; :age &amp;lt;= 12, :height,
			:Sex == "M" &amp;amp; :age &amp;gt; 13, :weight,
			:Sex == "M" &amp;amp; :age &amp;lt;= 13, :height
		)
	)
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_1-1633556203964.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/36379i95A0EB3F45FBF356/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_1-1633556203964.png" alt="txnelson_1-1633556203964.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 21:36:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Saving-Variables-to-New-Tables-and-New-Columns/m-p/424114#M67332</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-10-06T21:36:53Z</dc:date>
    </item>
    <item>
      <title>Re: Saving Variables to New Tables and New Columns</title>
      <link>https://community.jmp.com/t5/Discussions/Saving-Variables-to-New-Tables-and-New-Columns/m-p/424476#M67355</link>
      <description>&lt;P&gt;I provided this response to SMW privately; hopefully it will help others.&lt;/P&gt;
&lt;P&gt;Try running this code.&amp;nbsp; Look in the log window to see what happens.&amp;nbsp; The get rows where function returns a matrix, not an actual row number.&amp;nbsp; You have to loop over the matrix to use the row values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt1 = New Table( "Test", Add Rows( 4 ),
	New Column( "Column 1", Numeric, "Continuous", Format( "Best", 12 ),
		Set Values( [1, 2, 3, 4] ) ),
	New Column( "Column 2", Character, "Nominal",
		Set Values( {"This is EMOTIONAL", "abc", "EMO", "Here's an EMO example"} ) ),
	New Column( "Column 3", Character, "Nominal",
		Set Values(
			{"And not KLARIFIED", "KLA", "xyz", "This contains KLA string"} ) ),
	New Column( "Column 4", Numeric, "Continuous", Format( "Best", 12 ),
		Set Values( [., ., ., .] ) ),
	New Column( "Column 5", Numeric, "Continuous", Format( "Best", 12 ),
		Set Values( [., ., ., .] ) ),
	New Column( "Column 6", Numeric, "Continuous", Format( "Best", 12 ),
		Set Values( [., ., ., .] ) ),
	New Column( "Column 7", Character, "Nominal",
		Set Values( {"Hello", "World", "Fubar", "Ski"} ) ),
);

match_rows = dt1 &amp;lt;&amp;lt; get rows where(contains(as column(2),"EMO")
								 &amp;amp; contains(as column(3),"KLA"));

for (i = 1, i &amp;lt;= nrows(match_rows), i++,
	one_row = match_rows[i];
	apass   = column(dt1, 7)[one_row];
	print(apass);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Oct 2021 19:00:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Saving-Variables-to-New-Tables-and-New-Columns/m-p/424476#M67355</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2021-10-07T19:00:36Z</dc:date>
    </item>
    <item>
      <title>Re: Saving Variables to New Tables and New Columns</title>
      <link>https://community.jmp.com/t5/Discussions/Saving-Variables-to-New-Tables-and-New-Columns/m-p/424954#M67416</link>
      <description>&lt;P&gt;Thank you for taking the time to explain the issue.&amp;nbsp; Im very new to JSL scripting and I appreciate you taking the time to examine how a new column can be a complex formula.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Oct 2021 23:10:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Saving-Variables-to-New-Tables-and-New-Columns/m-p/424954#M67416</guid>
      <dc:creator>SMW</dc:creator>
      <dc:date>2021-10-08T23:10:27Z</dc:date>
    </item>
    <item>
      <title>Re: Saving Variables to New Tables and New Columns</title>
      <link>https://community.jmp.com/t5/Discussions/Saving-Variables-to-New-Tables-and-New-Columns/m-p/424961#M67417</link>
      <description>&lt;P&gt;Thanks again for the help pmroz.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Boiled down, the problem is as simple as finding rows that contain specific text in two columns. Then creating a new table with those rows and the corresponding value in column x of that row.&amp;nbsp; But it got really complicated using the wrong functions.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Oct 2021 23:15:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Saving-Variables-to-New-Tables-and-New-Columns/m-p/424961#M67417</guid>
      <dc:creator>SMW</dc:creator>
      <dc:date>2021-10-08T23:15:35Z</dc:date>
    </item>
    <item>
      <title>Re: Saving Variables to New Tables and New Columns</title>
      <link>https://community.jmp.com/t5/Discussions/Saving-Variables-to-New-Tables-and-New-Columns/m-p/424962#M67418</link>
      <description>&lt;P&gt;One side question.&amp;nbsp; If the data headers for the columns are simply column 1, column2, column 3....., how does the scoping syntax work .&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;If(
:Column2 =="text" &amp;amp; :Column3 =="text"

//Or would you use 
if(
:col[2] =="text" &amp;amp; :col[3]=="text"

//I'm a bit confused about the syntax in a situation where my output files headers
are not formatted very nicely. Specifically, they start at row 7.  I was trying to get around having to modify these tables by simply referencing the column #s&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;if you have any insight, thank you in advance.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Oct 2021 23:21:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Saving-Variables-to-New-Tables-and-New-Columns/m-p/424962#M67418</guid>
      <dc:creator>SMW</dc:creator>
      <dc:date>2021-10-08T23:21:03Z</dc:date>
    </item>
  </channel>
</rss>

