<?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: JSL keep command to keep wanted variables and delete unwanted variables? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JSL-keep-command-to-keep-wanted-variables-and-delete-unwanted/m-p/375321#M62519</link>
    <description>&lt;P&gt;A more direct method was added to JSL in JMP 14. Select columns, invert column selection, and delete columns can accomplish what is needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = open("$SAMPLE_DATA\Big Class.jmp");
a = {"height", "weight"};
dt &amp;lt;&amp;lt; select columns(a);
dt &amp;lt;&amp;lt; invert column selection;
b = dt &amp;lt;&amp;lt; get selected columns;
dt &amp;lt;&amp;lt; delete columns(b);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 08 Apr 2021 21:22:35 GMT</pubDate>
    <dc:creator>Audrey_Shull</dc:creator>
    <dc:date>2021-04-08T21:22:35Z</dc:date>
    <item>
      <title>JSL keep command to keep wanted variables and delete unwanted variables?</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-keep-command-to-keep-wanted-variables-and-delete-unwanted/m-p/19028#M17348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am looking for a JSL script command to "keep" only specified column variables, and delete all other variables in the current data table.&lt;/P&gt;&lt;P&gt;This would be the inverse of the specified command:&amp;nbsp; dt &amp;lt;&amp;lt; Delete Columns( :A, :B, ... :N);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ideally a more efficient keep command would appear like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dt = Current Data Table( );&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dt &amp;lt;&amp;lt; Keep Columns ( :time, :day, :location );&lt;/P&gt;&lt;P&gt;(outcome = Delete all columns that do not equal &lt;SPAN style="font-size: 13.3333px;"&gt;:time, :day, :location).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jun 2016 20:38:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-keep-command-to-keep-wanted-variables-and-delete-unwanted/m-p/19028#M17348</guid>
      <dc:creator>aandw</dc:creator>
      <dc:date>2016-06-13T20:38:50Z</dc:date>
    </item>
    <item>
      <title>Re: JSL keep command to keep wanted variables and delete unwanted variables?</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-keep-command-to-keep-wanted-variables-and-delete-unwanted/m-p/19029#M17349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I assume that you are making a feature enhancement request.&amp;nbsp; You will be better served if you submit this to &lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;A class="jive-link-email-small" href="mailto:support@jmp.com"&gt;support@jmp.com&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jun 2016 22:05:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-keep-command-to-keep-wanted-variables-and-delete-unwanted/m-p/19029#M17349</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2016-06-13T22:05:38Z</dc:date>
    </item>
    <item>
      <title>Re: JSL keep command to keep wanted variables and delete unwanted variables?</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-keep-command-to-keep-wanted-variables-and-delete-unwanted/m-p/19030#M17350</link>
      <description>&lt;P&gt;Until they add it to JSL you can try this:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.jmp.com/message/41338" target="_blank"&gt;Re: Deleting columns that are not in a list&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;it could be further developed and i found it very useful before using the table update command.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin-bottom: .0001pt;"&gt;Before updating tables it is useful to remove columns that have same name but you do not wish to update. The following will do it just by defining the to keep columns.&lt;/P&gt;
&lt;P style="margin-bottom: 0.0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt10 = New Table( "Test",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Add Rows( 10 ),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; New Column( "A" ),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; New Column( "B" ),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; New Column( "C" ),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; New Column( "D" )
);
Keep = {"A", "C"};
todelete = dt10 &amp;lt;&amp;lt; get column names( "string" );
For( in = 1, in &amp;lt;= N Items( Keep ), in++, &lt;BR /&gt;// assuming the to keep list is shorter than the list of columns in the table.
location = Contains( todelete, Keep[in]) ; // find the location of the keepers
if (location &amp;gt; 0, Remove From( todelete, location, 1 ) // if found remove it
));
if (nitems (todelete) &amp;gt; 0, dt10 &amp;lt;&amp;lt; delete columns( todelete )); &lt;BR /&gt;// if there is a delete list delete the columns from the table&lt;/CODE&gt;&lt;/PRE&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;
&lt;P&gt;if you ask the development team for this command ask them to make the same for rows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;best&lt;/P&gt;
&lt;P&gt;ron&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2018 16:27:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-keep-command-to-keep-wanted-variables-and-delete-unwanted/m-p/19030#M17350</guid>
      <dc:creator>ron_horne</dc:creator>
      <dc:date>2018-01-02T16:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: JSL keep command to keep wanted variables and delete unwanted variables?</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-keep-command-to-keep-wanted-variables-and-delete-unwanted/m-p/19031#M17351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you.&amp;nbsp; Y&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;our script above was helpful.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I modified slightly to operate in current data table, eg Data Table( "name_here") compared to creating a new data table and the outcome was successful.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jun 2016 19:35:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-keep-command-to-keep-wanted-variables-and-delete-unwanted/m-p/19031#M17351</guid>
      <dc:creator>aandw</dc:creator>
      <dc:date>2016-06-14T19:35:45Z</dc:date>
    </item>
    <item>
      <title>Re: JSL keep command to keep wanted variables and delete unwanted variables?</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-keep-command-to-keep-wanted-variables-and-delete-unwanted/m-p/19032#M17352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Probably a simpler solution that is easy to do manually (and script easily) is to just subset your data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select the Columns you want to keep and then subset with the Selected Columns(1) option.&amp;nbsp; This should also be faster than the method described above when the data table gets large, but I haven't tested it.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="11841_pastedImage_1.png" style="width: 465px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/3274i814E2735A50D9794/image-size/medium?v=v2&amp;amp;px=400" role="button" title="11841_pastedImage_1.png" alt="11841_pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Oct 2016 03:07:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-keep-command-to-keep-wanted-variables-and-delete-unwanted/m-p/19032#M17352</guid>
      <dc:creator>msharp</dc:creator>
      <dc:date>2016-10-19T03:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: JSL keep command to keep wanted variables and delete unwanted variables?</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-keep-command-to-keep-wanted-variables-and-delete-unwanted/m-p/375321#M62519</link>
      <description>&lt;P&gt;A more direct method was added to JSL in JMP 14. Select columns, invert column selection, and delete columns can accomplish what is needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = open("$SAMPLE_DATA\Big Class.jmp");
a = {"height", "weight"};
dt &amp;lt;&amp;lt; select columns(a);
dt &amp;lt;&amp;lt; invert column selection;
b = dt &amp;lt;&amp;lt; get selected columns;
dt &amp;lt;&amp;lt; delete columns(b);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Apr 2021 21:22:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-keep-command-to-keep-wanted-variables-and-delete-unwanted/m-p/375321#M62519</guid>
      <dc:creator>Audrey_Shull</dc:creator>
      <dc:date>2021-04-08T21:22:35Z</dc:date>
    </item>
  </channel>
</rss>

