<?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: Adding up all the columns with names stored in a list in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Adding-up-all-the-columns-with-names-stored-in-a-list/m-p/63145#M33915</link>
    <description>&lt;P&gt;Wow Jim, thank you,&lt;/P&gt;&lt;P&gt;This works perfect.&lt;/P&gt;</description>
    <pubDate>Tue, 17 Jul 2018 19:46:16 GMT</pubDate>
    <dc:creator>nguyendv06</dc:creator>
    <dc:date>2018-07-17T19:46:16Z</dc:date>
    <item>
      <title>Adding up all the columns with names stored in a list</title>
      <link>https://community.jmp.com/t5/Discussions/Adding-up-all-the-columns-with-names-stored-in-a-list/m-p/63125#M33908</link>
      <description>&lt;P&gt;I have create a list of column containing roughly the same name below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Xlist = {};&lt;BR /&gt;Ylist = {};&lt;/P&gt;&lt;P&gt;for(i = 1, i &amp;lt; ncols(dt2), i++,&lt;BR /&gt;if(&lt;BR /&gt;contains(dt2:i&amp;lt;&amp;lt; get name, "XXX") &amp;gt; 0, insert into(Xlist, dt2:i&amp;lt;&amp;lt; get name),&lt;BR /&gt;contains(dt2:i&amp;lt;&amp;lt; get name, "YYY") &amp;gt; 0, insert into(Ylist, dt2:i&amp;lt;&amp;lt; get name),&lt;BR /&gt;)&lt;BR /&gt;);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to create a new column which will give me a sum of the Xcolumn and Ycolumn. It is not working well for me at all. I must not be doing something right.... Please help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dt2 &amp;lt;&amp;lt; New Column( "Xsum", Numeric, Continuous, Format( "Best", 12 ),&lt;BR /&gt;Formula(&lt;BR /&gt;sum(eval(Xlist)),&lt;BR /&gt;)&lt;BR /&gt;);&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2018 18:53:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Adding-up-all-the-columns-with-names-stored-in-a-list/m-p/63125#M33908</guid>
      <dc:creator>nguyendv06</dc:creator>
      <dc:date>2018-07-17T18:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: Adding up all the columns with names stored in a list</title>
      <link>https://community.jmp.com/t5/Discussions/Adding-up-all-the-columns-with-names-stored-in-a-list/m-p/63141#M33912</link>
      <description>&lt;P&gt;The formula section within a New Column is not parsed and evaluated as one might expect.&amp;nbsp; I have found, that the best way to handle this, is to generate a literal string of the complete New Column phrase, exactly as you would want it if you manually typed it in, and then to execute that line.&amp;nbsp; The code below does that&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt2 = Current Data Table();

Xlist = "";
Ylist = "";

For( i = 1, i &amp;lt; N Cols( dt2 ), i++,
	If(
		Contains( column(dt2,i) &amp;lt;&amp;lt; get name, "XXX" ) &amp;gt; 0, Xlist=Xlist || ":" ||  char(column(dt2,i) &amp;lt;&amp;lt; get name) || ",",
		Contains( column(dt2,i) &amp;lt;&amp;lt; get name, "YYY" ) &amp;gt; 0, Ylist=Ylist || ":" ||  char(column(dt2,i) &amp;lt;&amp;lt; get name) || ","
	)
);

eval(parse("dt2 &amp;lt;&amp;lt; New Column( \!"Xsum\!", Numeric, Continuous, Format( \!"Best\!", 12 ), Formula( Sum( "||Xlist ||") ) );"));
eval(parse("dt2 &amp;lt;&amp;lt; New Column( \!"Ysum\!", Numeric, Continuous, Format( \!"Best\!", 12 ), Formula( Sum( "||Ylist ||") ) );"));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Jul 2018 19:38:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Adding-up-all-the-columns-with-names-stored-in-a-list/m-p/63141#M33912</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-07-17T19:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: Adding up all the columns with names stored in a list</title>
      <link>https://community.jmp.com/t5/Discussions/Adding-up-all-the-columns-with-names-stored-in-a-list/m-p/63145#M33915</link>
      <description>&lt;P&gt;Wow Jim, thank you,&lt;/P&gt;&lt;P&gt;This works perfect.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2018 19:46:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Adding-up-all-the-columns-with-names-stored-in-a-list/m-p/63145#M33915</guid>
      <dc:creator>nguyendv06</dc:creator>
      <dc:date>2018-07-17T19:46:16Z</dc:date>
    </item>
  </channel>
</rss>

