<?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 remove almost empty categorical columns in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/remove-almost-empty-categorical-columns/m-p/37293#M21874</link>
    <description>&lt;P&gt;Some one can help me?&lt;/P&gt;&lt;P&gt;From a database i need to remove categorical columns with a certain percentage of missing character and at the same time&amp;nbsp;I would like&amp;nbsp;to remove the&amp;nbsp;numeric columns with a percentage of stagnant values (not necessary 100%).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&amp;nbsp; Felice&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 16 Mar 2017 17:18:05 GMT</pubDate>
    <dc:creator>FR60</dc:creator>
    <dc:date>2017-03-16T17:18:05Z</dc:date>
    <item>
      <title>remove almost empty categorical columns</title>
      <link>https://community.jmp.com/t5/Discussions/remove-almost-empty-categorical-columns/m-p/37293#M21874</link>
      <description>&lt;P&gt;Some one can help me?&lt;/P&gt;&lt;P&gt;From a database i need to remove categorical columns with a certain percentage of missing character and at the same time&amp;nbsp;I would like&amp;nbsp;to remove the&amp;nbsp;numeric columns with a percentage of stagnant values (not necessary 100%).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&amp;nbsp; Felice&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 17:18:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/remove-almost-empty-categorical-columns/m-p/37293#M21874</guid>
      <dc:creator>FR60</dc:creator>
      <dc:date>2017-03-16T17:18:05Z</dc:date>
    </item>
    <item>
      <title>Re: remove almost empty categorical columns</title>
      <link>https://community.jmp.com/t5/Discussions/remove-almost-empty-categorical-columns/m-p/37295#M21876</link>
      <description>&lt;P&gt;Here is a quick and dirty script that gets rid of columns with less than a specified percent of data&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();
percent = 90;
colList = dt &amp;lt;&amp;lt; get column names( character, string );
NumRows = N Rows( dt );
For( i = N Items( colList ), i &amp;gt;= 1, i--,
	If( Col Number( Column( dt, i ) ) / NumRows * 100 &amp;lt; percent,
		dt &amp;lt;&amp;lt; delete columns( colList[i] )
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Mar 2017 17:34:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/remove-almost-empty-categorical-columns/m-p/37295#M21876</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-03-16T17:34:47Z</dc:date>
    </item>
    <item>
      <title>Re: remove almost empty categorical columns</title>
      <link>https://community.jmp.com/t5/Discussions/remove-almost-empty-categorical-columns/m-p/37307#M21883</link>
      <description>&lt;P&gt;Another method, I believe slightly more robust.&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();
percent = 90;
delcols = {};
numRows = nrows(dt);
for(i=1; maxi=NCols(dt), i&amp;lt;=maxi, i++,
	col = column(dt, i);
	nmissing = col N missing(col);
	if(nmissing &amp;gt; numRows * percent/100,
		insert into(delcols, i);
	);
);
if(nitems(delcols) &amp;gt; 0, dt &amp;lt;&amp;lt; delete columns(delcols));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 19:08:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/remove-almost-empty-categorical-columns/m-p/37307#M21883</guid>
      <dc:creator>msharp</dc:creator>
      <dc:date>2017-03-16T19:08:25Z</dc:date>
    </item>
    <item>
      <title>Re: remove almost empty categorical columns</title>
      <link>https://community.jmp.com/t5/Discussions/remove-almost-empty-categorical-columns/m-p/37309#M21884</link>
      <description>&lt;P&gt;I think you are also looking for something like this:&lt;/P&gt;
&lt;P&gt;Which will delete a numeric column if all data is only one value.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();
delcols = {};
numRows = nrows(dt);
for(i=1; maxi=NCols(dt), i&amp;lt;=maxi, i++,
	col = column(dt, i);
	try(summarize(dt, max = max(col), min = min(col));
		if((max == min)  | (ismissing(max)),
			insertinto(delcols, i);
		)
	);
);
if(nitems(delcols) &amp;gt; 0, dt &amp;lt;&amp;lt; delete columns(delcols));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Mar 2017 19:12:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/remove-almost-empty-categorical-columns/m-p/37309#M21884</guid>
      <dc:creator>msharp</dc:creator>
      <dc:date>2017-03-16T19:12:44Z</dc:date>
    </item>
    <item>
      <title>Re: remove almost empty categorical columns</title>
      <link>https://community.jmp.com/t5/Discussions/remove-almost-empty-categorical-columns/m-p/37316#M21890</link>
      <description>&lt;P&gt;you might be able to use the method you posted before but with the mode of the column for something less than 100%&lt;/P&gt;&lt;PRE&gt;Names Default To Here( 1 );
dt = Current Data Table();
percent = 90;
delcols = {};
numRows = nrows(dt);
for(i=1; maxi=NCols(dt), i&amp;lt;=maxi, i++,
	if(nrows(loc(aslist(column(dt,i)&amp;lt;&amp;lt;getasmatrix),mode(column(dt,i)&amp;lt;&amp;lt;getasmatrix))) &amp;gt; numRows * percent/100,
		insert into(delcols, i);
	);
);
if(nitems(delcols) &amp;gt; 0, dt &amp;lt;&amp;lt; delete columns(delcols));&amp;nbsp;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2017 01:06:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/remove-almost-empty-categorical-columns/m-p/37316#M21890</guid>
      <dc:creator>mpl34</dc:creator>
      <dc:date>2017-03-17T01:06:34Z</dc:date>
    </item>
    <item>
      <title>Re: remove almost empty categorical columns</title>
      <link>https://community.jmp.com/t5/Discussions/remove-almost-empty-categorical-columns/m-p/37332#M21903</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I tried yor script on the second table below and the result is here.&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see it was able to remove almost all desired columns but second one (col2) not.&amp;nbsp;How I can do to remove it too?&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp; Felice&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="Picture2.png" style="width: 350px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/5647i2EA70C1AE8EA5731/image-size/large?v=v2&amp;amp;px=999" role="button" title="Picture2.png" alt="Picture2.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Picture1.png" style="width: 971px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/5648i40A2BFEE769CA6D1/image-size/large?v=v2&amp;amp;px=999" role="button" title="Picture1.png" alt="Picture1.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2017 14:52:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/remove-almost-empty-categorical-columns/m-p/37332#M21903</guid>
      <dc:creator>FR60</dc:creator>
      <dc:date>2017-03-17T14:52:37Z</dc:date>
    </item>
    <item>
      <title>Re: remove almost empty categorical columns</title>
      <link>https://community.jmp.com/t5/Discussions/remove-almost-empty-categorical-columns/m-p/37333#M21904</link>
      <description>&lt;P&gt;Just combine the strategies. &amp;nbsp;Something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();
percent = 90;
delcols = {};
numRows = nrows(dt);
for(i=1; maxi=NCols(dt), i&amp;lt;=maxi, i++,
	if(nrows(loc(aslist(column(dt,i)&amp;lt;&amp;lt;getasmatrix),mode(column(dt,i)&amp;lt;&amp;lt;getasmatrix))) &amp;gt; numRows * percent/100,
		insert into(delcols, i);
	,
		if(Col N Missing(column(dt,i)) &amp;gt; numRows * percent/100,
			insert into(delcols, i);
		);
	);
);
if(nitems(delcols) &amp;gt; 0, dt &amp;lt;&amp;lt; delete columns(delcols));  &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Mar 2017 15:20:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/remove-almost-empty-categorical-columns/m-p/37333#M21904</guid>
      <dc:creator>msharp</dc:creator>
      <dc:date>2017-03-17T15:20:45Z</dc:date>
    </item>
    <item>
      <title>Re: remove almost empty categorical columns</title>
      <link>https://community.jmp.com/t5/Discussions/remove-almost-empty-categorical-columns/m-p/37338#M21908</link>
      <description>&lt;P&gt;Hi msharp thanks for your reply. Let'm ask another question. The percent variable&amp;nbsp;work for both on categorical and numerical columns? If yes can I have two different value for missing and stagnant cases?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for maybe stupid question but I'm not expert&amp;nbsp;in&amp;nbsp;jsl language.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Felice&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2017 16:02:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/remove-almost-empty-categorical-columns/m-p/37338#M21908</guid>
      <dc:creator>FR60</dc:creator>
      <dc:date>2017-03-17T16:02:07Z</dc:date>
    </item>
    <item>
      <title>Re: remove almost empty categorical columns</title>
      <link>https://community.jmp.com/t5/Discussions/remove-almost-empty-categorical-columns/m-p/37342#M21912</link>
      <description>Yeah it all depends on how you set it up.  The first check is finding the most common value in each column and determines if it is above or below the threshold percentage.  Unfortunately, a missing value isn't a value, so it can't be the most common.  That's why it doesn't work on the numeric columns.  It does work on the Character columns b/c "" is both missing and an empty string value.&lt;BR /&gt;&lt;BR /&gt;Hope that helps explain things.&lt;BR /&gt;&lt;BR /&gt;If you want more granularity, just run multiple loops with different percentages using different strategies.</description>
      <pubDate>Fri, 17 Mar 2017 16:41:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/remove-almost-empty-categorical-columns/m-p/37342#M21912</guid>
      <dc:creator>msharp</dc:creator>
      <dc:date>2017-03-17T16:41:59Z</dc:date>
    </item>
    <item>
      <title>Re: remove almost empty categorical columns</title>
      <link>https://community.jmp.com/t5/Discussions/remove-almost-empty-categorical-columns/m-p/37343#M21913</link>
      <description>&lt;P&gt;Perfect thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Felice&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2017 16:53:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/remove-almost-empty-categorical-columns/m-p/37343#M21913</guid>
      <dc:creator>FR60</dc:creator>
      <dc:date>2017-03-17T16:53:13Z</dc:date>
    </item>
  </channel>
</rss>

