<?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 script to select all cols that contain a list of values? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/script-to-select-all-cols-that-contain-a-list-of-values/m-p/681830#M86746</link>
    <description>&lt;P&gt;I've got a large dt (70k cols, character) that I'm digging through. Most cols have a wide range of values, but a noticeable population of them have only two nuisance values. I want to identify all these cols and then dump them.&lt;BR /&gt;&lt;BR /&gt;Any advice?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;These nuisance cols will contain ONLY the terms "**skipped**" or "dne".&lt;/P&gt;&lt;P&gt;I've already dumped all cols that contain a single record value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LambdaMarmoset7_0-1695858814574.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/57048iAAF86379F994CAC1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LambdaMarmoset7_0-1695858814574.png" alt="LambdaMarmoset7_0-1695858814574.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 27 Sep 2023 23:54:52 GMT</pubDate>
    <dc:creator>LambdaMarmoset7</dc:creator>
    <dc:date>2023-09-27T23:54:52Z</dc:date>
    <item>
      <title>script to select all cols that contain a list of values?</title>
      <link>https://community.jmp.com/t5/Discussions/script-to-select-all-cols-that-contain-a-list-of-values/m-p/681830#M86746</link>
      <description>&lt;P&gt;I've got a large dt (70k cols, character) that I'm digging through. Most cols have a wide range of values, but a noticeable population of them have only two nuisance values. I want to identify all these cols and then dump them.&lt;BR /&gt;&lt;BR /&gt;Any advice?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;These nuisance cols will contain ONLY the terms "**skipped**" or "dne".&lt;/P&gt;&lt;P&gt;I've already dumped all cols that contain a single record value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LambdaMarmoset7_0-1695858814574.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/57048iAAF86379F994CAC1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LambdaMarmoset7_0-1695858814574.png" alt="LambdaMarmoset7_0-1695858814574.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2023 23:54:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/script-to-select-all-cols-that-contain-a-list-of-values/m-p/681830#M86746</guid>
      <dc:creator>LambdaMarmoset7</dc:creator>
      <dc:date>2023-09-27T23:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: script to select all cols that contain a list of values?</title>
      <link>https://community.jmp.com/t5/Discussions/script-to-select-all-cols-that-contain-a-list-of-values/m-p/681849#M86749</link>
      <description>&lt;P&gt;Here is a sample script&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

// Create a sample data table to be used for illustration 
dt = New Table( "Example", add rows( 20 ) );
dt &amp;lt;&amp;lt; delete columns( :Column 1 );
For( i = 1, i &amp;lt;= 100, i++,
	If( randomuniform( 0, 1 ) &amp;gt; .95,
		If( Random Uniform( 0, 1 ) &amp;gt; .5,
			dt &amp;lt;&amp;lt; New Column( "col" || Char( i ),
				character,
				values( {"**skipped**"} )
			),
			dt &amp;lt;&amp;lt; New Column( "col" || Char( i ),
				character,
				values( {"dne"} )
			)
		),
		dt &amp;lt;&amp;lt; New Column( "col" || Char( i ),
			character,
			set each value( Char( Random Uniform( 0, 100 ) ) )
		)
	)
);

// Below is the simple script that will build a list of columns to be deleted,
// and then delete them
colNames = dt &amp;lt;&amp;lt; get column names(string,character);

colsToDelete = {};
For Each( {name}, colnames,
	If(
		N Rows(
			(dt &amp;lt;&amp;lt; get rows where(
				as Column( name ) == "**skipped**" | As Column( name ) ==
				"dne"
			))
		),
		Insert Into( colsToDelete, name )
	)
);

dt &amp;lt;&amp;lt; delete columns( colsToDelete );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Sep 2023 01:33:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/script-to-select-all-cols-that-contain-a-list-of-values/m-p/681849#M86749</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2023-09-28T01:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: script to select all cols that contain a list of values?</title>
      <link>https://community.jmp.com/t5/Discussions/script-to-select-all-cols-that-contain-a-list-of-values/m-p/681881#M86756</link>
      <description>&lt;P&gt;Depending on your data and the speed you need, you might want to change how you get the list of unique values, but below is one option&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = New Table("Untitled 4",
	Add Rows(3),
	Compress File When Saved(1),
	New Column("Column 1", Character, "Nominal", Set Values({"dne", "**skipped**", "**skipped**"})),
	New Column("Column 2", Character, "Nominal", Set Values({"dne", "a", "b"})),
	New Column("Column 3", Character, "Nominal", Set Values({"**skipped**", "c", "d"})),
	New Column("Column 4", Character, "Nominal", Set Values({"dne", "dne", "**skipped**"}))
);

aa_colmask = ["dne" =&amp;gt; 1, "**skipped**" =&amp;gt; 1]; // we don't need the values, just keys

cols_to_remove = {};

For Each({colname}, dt &amp;lt;&amp;lt; Get Column Names("String"),
	// depending on how much data you have, you might want to use different unique value techniques
	// Summarize, Associative Array and Summary are few options.
	// You can also first check if there are exactly 2 unique values, then check those
	aa_values = Associative Array(Column(dt, colname)); // I use AA here as it is the easiest option (not fastest!)
	aa_values &amp;lt;&amp;lt; Remove(aa_colmask);
	If(N Items(aa_values) == 0,
		Insert Into(cols_to_remove, colname);
	);
);

dt &amp;lt;&amp;lt; Delete Columns(cols_to_remove);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 28 Sep 2023 05:49:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/script-to-select-all-cols-that-contain-a-list-of-values/m-p/681881#M86756</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-09-28T05:49:35Z</dc:date>
    </item>
  </channel>
</rss>

