<?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: How to script an aggregate column from a variable list of column references in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-script-an-aggregate-column-from-a-variable-list-of-column/m-p/534376#M75699</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Try this syntax:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names default to Here (1);

dt = Current Data Table ();

cols = {:col1, :col2, :col3};

dt &amp;lt;&amp;lt; New Column("TEST", numerical, continuous, &amp;lt;&amp;lt; Formula(Minimum(Eval(cols))));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;TS&lt;/P&gt;</description>
    <pubDate>Tue, 16 Aug 2022 18:02:11 GMT</pubDate>
    <dc:creator>Thierry_S</dc:creator>
    <dc:date>2022-08-16T18:02:11Z</dc:date>
    <item>
      <title>How to script an aggregate column from a variable list of column references</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-script-an-aggregate-column-from-a-variable-list-of-column/m-p/534368#M75697</link>
      <description>&lt;P&gt;I have a list of columns that I need to aggregate automatically. Currently, what I'm trying is something like this, which isn't yielding any results.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;cols = {:col1, :col2, :col3}

Eval(Eval Expr(
  dt &amp;lt;&amp;lt; New Column(
    Formula(Minimum(Expr(cols))
  )
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I've also tried generating this interactively and saving the column formula. It works, but gives me&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Minimum(:col1, :col2, :col3)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;which I'm not sure how to re-create in JSL.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 17:07:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-script-an-aggregate-column-from-a-variable-list-of-column/m-p/534368#M75697</guid>
      <dc:creator>jconte</dc:creator>
      <dc:date>2023-06-09T17:07:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to script an aggregate column from a variable list of column references</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-script-an-aggregate-column-from-a-variable-list-of-column/m-p/534373#M75698</link>
      <description>&lt;P&gt;This might give some ideas &lt;LI-MESSAGE title="Using list of columns in formulas" uid="405133" url="https://community.jmp.com/t5/Discussions/Using-list-of-columns-in-formulas/m-p/405133#U405133" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-SPOILER&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");

cols = {:height, :weight};

// this should work, but formula looks "weird" due to brackets {}
Eval(Eval Expr(
	col1 = dt &amp;lt;&amp;lt; New Column("with_brackets", Numeric, Continuous, Formula(Minimum(Expr(cols))))
));

min_f = Substitute(cols, Expr(List()), Expr(Minimum()));
Eval(Eval Expr(
	col2 = dt &amp;lt;&amp;lt; New Column("no_brackets", Numeric, Continuous, Formula(Expr(NameExpr(min_f))))
));

show(col1 &amp;lt;&amp;lt; get formula, col2 &amp;lt;&amp;lt; get formula);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI-SPOILER&gt;</description>
      <pubDate>Tue, 16 Aug 2022 17:57:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-script-an-aggregate-column-from-a-variable-list-of-column/m-p/534373#M75698</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-08-16T17:57:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to script an aggregate column from a variable list of column references</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-script-an-aggregate-column-from-a-variable-list-of-column/m-p/534376#M75699</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Try this syntax:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names default to Here (1);

dt = Current Data Table ();

cols = {:col1, :col2, :col3};

dt &amp;lt;&amp;lt; New Column("TEST", numerical, continuous, &amp;lt;&amp;lt; Formula(Minimum(Eval(cols))));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;TS&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 18:02:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-script-an-aggregate-column-from-a-variable-list-of-column/m-p/534376#M75699</guid>
      <dc:creator>Thierry_S</dc:creator>
      <dc:date>2022-08-16T18:02:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to script an aggregate column from a variable list of column references</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-script-an-aggregate-column-from-a-variable-list-of-column/m-p/534381#M75700</link>
      <description>&lt;P&gt;Thanks for the quick response! I tried this, but it seems to leave the column formula unresolved (as Minimum(Eval(cols)) ).&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 18:17:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-script-an-aggregate-column-from-a-variable-list-of-column/m-p/534381#M75700</guid>
      <dc:creator>jconte</dc:creator>
      <dc:date>2022-08-16T18:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to script an aggregate column from a variable list of column references</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-script-an-aggregate-column-from-a-variable-list-of-column/m-p/534384#M75701</link>
      <description>&lt;P&gt;Please check your list definition and make sure the ":" is specified in front of each column name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What version of JMP are you using?&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 18:31:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-script-an-aggregate-column-from-a-variable-list-of-column/m-p/534384#M75701</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-08-16T18:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to script an aggregate column from a variable list of column references</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-script-an-aggregate-column-from-a-variable-list-of-column/m-p/534403#M75703</link>
      <description>&lt;P&gt;My actual list is defined through regex matching based on user input. The script iterates through the data table's list of column names and inserts matching ones into a list.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For Each ({col}, colNames,
  If (condition... Insert Into(list, :Column(col))
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I tried changing the syntax to &lt;CODE&gt;:(Column(col))&lt;/CODE&gt; but that resulted in a list of missing items rather than what I had previously been getting (&lt;CODE&gt;{Column(col1), Column(col2), ...}&lt;/CODE&gt;). Same goes for &lt;CODE&gt;As Column(col)&lt;/CODE&gt;.&lt;/P&gt;&lt;P&gt;I'm using JMP 16.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 20:00:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-script-an-aggregate-column-from-a-variable-list-of-column/m-p/534403#M75703</guid>
      <dc:creator>jconte</dc:creator>
      <dc:date>2022-08-16T20:00:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to script an aggregate column from a variable list of column references</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-script-an-aggregate-column-from-a-variable-list-of-column/m-p/534424#M75704</link>
      <description>&lt;P&gt;I am guessing on what your initial column names list looks like, but if it is just an unquoted list o column names, the below script is an example of onw way to process it&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = 
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "/C:/Program Files/SAS/JMPPRO/15/Samples/Data/Big Class.jmp" );

colNames = dt &amp;lt;&amp;lt; get column names;
theList = {};
For Each( {col}, colNames,
	Show( col );
	If( As Column( col ) &amp;lt;&amp;lt; get data type == "Numeric",
		Insert Into( theList, As Column( col ) &amp;lt;&amp;lt; get name )
	);
);

theString = Concat Items( theList, ",:" );

Eval( Parse( "dt &amp;lt;&amp;lt; new column(\!"test\!",formula(minimum(:" || thestring || ")));" ) );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Aug 2022 20:40:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-script-an-aggregate-column-from-a-variable-list-of-column/m-p/534424#M75704</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-08-16T20:40:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to script an aggregate column from a variable list of column references</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-script-an-aggregate-column-from-a-variable-list-of-column/m-p/534425#M75705</link>
      <description>&lt;P&gt;Here are two methods you might try:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
cols = dt &amp;lt;&amp;lt; Get Column Names( "String" );
col list = {};
For Each( {col}, cols,
	If( Ends With( col, "t" ), Insert Into( col list, As Name( col ) ) )
);
Eval( Eval Expr(
dt &amp;lt;&amp;lt; New Column( "NEW_COL", "Numeric", &amp;lt;&amp;lt;Set Formula( Min( Eval List( Expr( col list ) ) ) ) )
) )&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
cols = dt &amp;lt;&amp;lt; Get Column Names( "String" );
col list = Expr( Min() );
For Each( {col}, cols,
	If( Ends With( col, "t" ), Insert Into( col list, As Name( col ) ) )
);
Eval( Eval Expr(
dt &amp;lt;&amp;lt; New Column( "NEW_COL", "Numeric", &amp;lt;&amp;lt;Set Formula( Expr( Name Expr( col list ) ) ) )
) )&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Aug 2022 20:47:14 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-script-an-aggregate-column-from-a-variable-list-of-column/m-p/534425#M75705</guid>
      <dc:creator>ErraticAttack</dc:creator>
      <dc:date>2022-08-16T20:47:14Z</dc:date>
    </item>
  </channel>
</rss>

