<?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: Exclude selected columns in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Exclude-selected-columns/m-p/521516#M74667</link>
    <description>&lt;P&gt;Thank you for your reply, jthi!&amp;nbsp; That was fast!&lt;BR /&gt;&lt;BR /&gt;Just saw your reply. I've been trying different things and I came up with a very simple 2 line solution.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;cols = {"Col A", "Col B"};
dt &amp;lt;&amp;lt; Select Columns(cols) &amp;lt;&amp;lt; Invert Column Selection;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I've never seen associative arrays used, and when I tried to use one in place of what I currently have for col, Select Columns selected a column that wasn't in cols, but was only 1 of the inverted selection. Strange.&amp;nbsp; Do you know why that might be?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;cols = Associative Array({"Col A", "Col B"});
dt &amp;lt;&amp;lt; Select Columns(cols) &amp;lt;&amp;lt; Invert Column Selection;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 14 Jul 2022 20:37:09 GMT</pubDate>
    <dc:creator>StarfruitBob</dc:creator>
    <dc:date>2022-07-14T20:37:09Z</dc:date>
    <item>
      <title>Exclude selected columns</title>
      <link>https://community.jmp.com/t5/Discussions/Exclude-selected-columns/m-p/73631#M35772</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get a varying list of columns from a source and select these columns in my data table. The data table has many other columns, but I want to hide/exclude the columns which are not in the list provided to me while my script is running and doing some analysis...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can select all the columns which I don't need by line below:&lt;/P&gt;&lt;P&gt;dt &amp;lt; &amp;lt;invert column selection (Provided_List)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Next step: Exclude these selected columns. How do I do that?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From&amp;nbsp;scripting book, I can see &lt;STRONG&gt;column("X") &amp;lt;&amp;lt; exclude(1)&amp;nbsp;&lt;/STRONG&gt;would&amp;nbsp;exclude the column with name X, but is there a&amp;nbsp;method to exclude already selected columns?&lt;BR /&gt;&lt;BR /&gt;Thanks.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 01:34:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Exclude-selected-columns/m-p/73631#M35772</guid>
      <dc:creator>aumair</dc:creator>
      <dc:date>2018-09-19T01:34:41Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude selected columns</title>
      <link>https://community.jmp.com/t5/Discussions/Exclude-selected-columns/m-p/73657#M35773</link>
      <description>&lt;P&gt;Here is the syntax of how to do 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" );

Column( dt, 4 ) &amp;lt;&amp;lt; set selected( 1 );
Column( dt, 5 ) &amp;lt;&amp;lt; set selected( 1 );

selcols = dt &amp;lt;&amp;lt; get selected columns;
For( i = 1, i &amp;lt;= N Items( selcols ), i++,
	Column( dt, selcols[i] ) &amp;lt;&amp;lt; exclude( 1 )
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Sep 2018 02:26:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Exclude-selected-columns/m-p/73657#M35773</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-09-19T02:26:30Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude selected columns</title>
      <link>https://community.jmp.com/t5/Discussions/Exclude-selected-columns/m-p/73693#M35774</link>
      <description>&lt;P&gt;Thanks!!! I also figured that out but it was a bit longer. This is perfect :)&lt;/img&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 02:53:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Exclude-selected-columns/m-p/73693#M35774</guid>
      <dc:creator>aumair</dc:creator>
      <dc:date>2018-09-19T02:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude selected columns</title>
      <link>https://community.jmp.com/t5/Discussions/Exclude-selected-columns/m-p/521491#M74665</link>
      <description>&lt;P&gt;Sorry to resurrect&amp;nbsp;this thread, but I have the same question and I wanted direction if this approach like this would work and how to improve it:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//List of wanted columns&lt;BR /&gt;col_names = (":Col A", ":Col B", etc);
&lt;BR /&gt;//Iterates through list and uses the string names to identify and select
for( i = 1, i &amp;lt;= N Items(dt), i++,
    Column( dt, col_names[i] ) &amp;lt;&amp;lt; set selected
);

dt &amp;lt;&amp;lt; Invert Column Selection&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jul 2022 19:26:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Exclude-selected-columns/m-p/521491#M74665</guid>
      <dc:creator>StarfruitBob</dc:creator>
      <dc:date>2022-07-14T19:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude selected columns</title>
      <link>https://community.jmp.com/t5/Discussions/Exclude-selected-columns/m-p/521501#M74666</link>
      <description>&lt;P&gt;You should use N Items(col_names) instead of N Items(dt) in the for loop.&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 = {"age", "sex", "weight"};
for( i = 1, i &amp;lt;= N Items(col_names), i++,
    Column( dt, col_names[i] ) &amp;lt;&amp;lt; set selected;
);
dt &amp;lt;&amp;lt; Invert Column Selection;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also you can make the code simpler by using Select Columns&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 = {"age", "sex", "weight"};
wait(1); // for demo purposes
dt &amp;lt;&amp;lt; Select Columns(col_names);
wait(1); // for demo purposes
dt &amp;lt;&amp;lt; Invert Column Selection;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can also avoid inverting by selecting correct columns directly, but it is most likely more difficult to understand&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 = Associative Array({"age", "sex", "weight"});
all_col_names = Associative Array(dt &amp;lt;&amp;lt; Get Column Names("String"));
all_col_names &amp;lt;&amp;lt; Remove(col_names);
dt &amp;lt;&amp;lt; Select Columns(all_col_names &amp;lt;&amp;lt; get keys);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Jul 2022 19:46:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Exclude-selected-columns/m-p/521501#M74666</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-07-14T19:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude selected columns</title>
      <link>https://community.jmp.com/t5/Discussions/Exclude-selected-columns/m-p/521516#M74667</link>
      <description>&lt;P&gt;Thank you for your reply, jthi!&amp;nbsp; That was fast!&lt;BR /&gt;&lt;BR /&gt;Just saw your reply. I've been trying different things and I came up with a very simple 2 line solution.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;cols = {"Col A", "Col B"};
dt &amp;lt;&amp;lt; Select Columns(cols) &amp;lt;&amp;lt; Invert Column Selection;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I've never seen associative arrays used, and when I tried to use one in place of what I currently have for col, Select Columns selected a column that wasn't in cols, but was only 1 of the inverted selection. Strange.&amp;nbsp; Do you know why that might be?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;cols = Associative Array({"Col A", "Col B"});
dt &amp;lt;&amp;lt; Select Columns(cols) &amp;lt;&amp;lt; Invert Column Selection;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Jul 2022 20:37:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Exclude-selected-columns/m-p/521516#M74667</guid>
      <dc:creator>StarfruitBob</dc:creator>
      <dc:date>2022-07-14T20:37:09Z</dc:date>
    </item>
    <item>
      <title>Re: Exclude selected columns</title>
      <link>https://community.jmp.com/t5/Discussions/Exclude-selected-columns/m-p/521675#M74672</link>
      <description>&lt;P&gt;This is because Associative Arrays will save key value pair and most likely when you use Select Columns directly with associative array it doesn't really know what to do. Usually it shouldn't select anything and then inverting it would select all columns (there might be some cases where the associative array would evaluate as 1 so it would select first column).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get they keys out of associative array, you can use &amp;lt;&amp;lt; get keys.&amp;nbsp;&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);

cols_list = {"Col A", "Col B"};
cols_aa = Associative Array({"Col A", "Col B"});

Show(cols_list);
Show(cols_aa);
Show(cols_aa &amp;lt;&amp;lt; get keys);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can read more about associative arrays from JMP Help page&amp;nbsp;&lt;A href="https://www.jmp.com/support/help/en/16.2/#page/jmp/associative-arrays.shtml" target="_blank" rel="noopener"&gt;Scripting Guide &amp;gt; Data Structures &amp;gt; Associative Arrays&lt;/A&gt;&amp;nbsp;. I this case I might have used them due to their set operations&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jul 2022 05:44:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Exclude-selected-columns/m-p/521675#M74672</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-07-15T05:44:36Z</dc:date>
    </item>
  </channel>
</rss>

