<?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: Prepping list column names for future use in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Prepping-list-column-names-for-future-use/m-p/568367#M77906</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I had the same problem a while back. The solution is simple: you need to evaluate the list to return the series of columns.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; Ungroup Scripts( Eval (col_list ));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;TS&lt;/P&gt;</description>
    <pubDate>Sat, 12 Nov 2022 01:31:49 GMT</pubDate>
    <dc:creator>Thierry_S</dc:creator>
    <dc:date>2022-11-12T01:31:49Z</dc:date>
    <item>
      <title>Prepping list column names for future use</title>
      <link>https://community.jmp.com/t5/Discussions/Prepping-list-column-names-for-future-use/m-p/568339#M77905</link>
      <description>&lt;P&gt;Hello, I'm trying to retrieve and prep a list of column names to save in a variable to use later. The issue is that &amp;lt;&amp;lt; Get Column Names() returns everything as a list of strings. Below is how I've added in a " : " to the beginning of each item string and what a potential usage of this may be. More still needs to be done.&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);
dt = current data table();

col_names = dt &amp;lt;&amp;lt; Get Column Names( );  // retrieves all col names
col_list = {};  // list for holding col names

// loop formats names in way usable to be called on as cols, not strings
for( i = 1 , i &amp;lt;= N items( col_names ), i++,
	list_item = ":" || list_item;
	Insert Into( col_list, list_item );
);

dt &amp;lt;&amp;lt; Ungroup Scripts( col_list ); // example usage&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Another example would be usage of this list into something like:&lt;/P&gt;&lt;P&gt;Fit Model(&amp;nbsp;Y( col_list )&amp;nbsp;....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I get: { "ColA", "ColB" }&lt;/P&gt;&lt;P&gt;What I want: { :ColA, :ColB }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've browsed and found multiple related threads about this, but the usage of the column names as an input for a function is something I didn't stumble across.&amp;nbsp; Any advice?&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 16:02:14 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Prepping-list-column-names-for-future-use/m-p/568339#M77905</guid>
      <dc:creator>StarfruitBob</dc:creator>
      <dc:date>2023-06-09T16:02:14Z</dc:date>
    </item>
    <item>
      <title>Re: Prepping list column names for future use</title>
      <link>https://community.jmp.com/t5/Discussions/Prepping-list-column-names-for-future-use/m-p/568367#M77906</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I had the same problem a while back. The solution is simple: you need to evaluate the list to return the series of columns.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; Ungroup Scripts( Eval (col_list ));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;TS&lt;/P&gt;</description>
      <pubDate>Sat, 12 Nov 2022 01:31:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Prepping-list-column-names-for-future-use/m-p/568367#M77906</guid>
      <dc:creator>Thierry_S</dc:creator>
      <dc:date>2022-11-12T01:31:49Z</dc:date>
    </item>
    <item>
      <title>Re: Prepping list column names for future use</title>
      <link>https://community.jmp.com/t5/Discussions/Prepping-list-column-names-for-future-use/m-p/568421#M77911</link>
      <description>&lt;P&gt;If you want to use columns formatted as :colname, you can get them for example with something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");

col_names = dt &amp;lt;&amp;lt; Get Column Names(Continuous, "String"); 
 // dt &amp;lt;&amp;lt; Get Column Reference(); /* all references */

/* one option */
col_list1 = dt &amp;lt;&amp;lt; Get Column Reference(col_names);

/* second option */
col_list2 = Transform Each({col_name}, col_names,
	Name Expr(AsColumn(Column(dt, col_name))); /* Column() isnt necessary but makes it more robust */
);

show(col_list1, col_list2);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Usually I use them as strings and then use Column() or As Column() depending on the situation (with some Name Expr() in the mix).&lt;/P&gt;
&lt;P&gt;Quite often using list of strings of column names is enough if you combine that with Eval().&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Cities.jmp");
col_names = {"OZONE", "CO", "SO2", "NO", "PM10"};

//obj = dt &amp;lt;&amp;lt; Cluster Variables(Y(:OZONE, :CO, :SO2, :NO, :PM10));
obj = dt &amp;lt;&amp;lt; Cluster Variables(Y(Eval(col_names)));


col_list = Transform Each({col_name}, col_names,
	Name Expr(AsColumn(Column(dt, col_name)));
);

obj = dt &amp;lt;&amp;lt; Cluster Variables(Y(col_list)); /* wont work, see log for error */

/* Using Eval() and Eval Expr() */
cv_expr = EvalExpr(
	obj = dt &amp;lt;&amp;lt; Cluster Variables(Y(Expr(col_list)));
);
Eval(cv_expr);

/* using only Eval inside Y() should also work like earlier */
obj = dt &amp;lt;&amp;lt; Cluster Variables(Y(Eval(col_list)));
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 12 Nov 2022 09:19:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Prepping-list-column-names-for-future-use/m-p/568421#M77911</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-11-12T09:19:55Z</dc:date>
    </item>
    <item>
      <title>Re: Prepping list column names for future use</title>
      <link>https://community.jmp.com/t5/Discussions/Prepping-list-column-names-for-future-use/m-p/569508#M78010</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/11634"&gt;@Thierry_S&lt;/a&gt;&amp;nbsp;&amp;amp; &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;- thank you both! eval() was what I was looking for! I understood that the column was an expression, but I completely forgot about this command.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2022 17:05:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Prepping-list-column-names-for-future-use/m-p/569508#M78010</guid>
      <dc:creator>StarfruitBob</dc:creator>
      <dc:date>2022-11-15T17:05:56Z</dc:date>
    </item>
  </channel>
</rss>

