<?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: delete CHAR cols if there's only a single value, no string variation in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/delete-CHAR-cols-if-there-s-only-a-single-value-no-string/m-p/808478#M98794</link>
    <description>&lt;P&gt;One thing to note: both me and Jim remove missing value from our list of unique values. Depending on your data/model/use case you might want to (or have to) consider that as a separate value so take that into account. Both our scripts can take that into account BUT they do need small changes.&lt;/P&gt;</description>
    <pubDate>Sat, 26 Oct 2024 17:14:20 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2024-10-26T17:14:20Z</dc:date>
    <item>
      <title>delete CHAR cols if there's only a single value, no string variation</title>
      <link>https://community.jmp.com/t5/Discussions/delete-CHAR-cols-if-there-s-only-a-single-value-no-string/m-p/808400#M98781</link>
      <description>&lt;P&gt;Wondering how I can script something to look at all the columns to see if there's at least 2 different values and delete all the single-value cols? I have thousands of 'feature' cols, all character-type, but a noticeable amount of them only have a single record in them...aka the distribution level = 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how to detect and delete 1-record cols?&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2024 22:07:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/delete-CHAR-cols-if-there-s-only-a-single-value-no-string/m-p/808400#M98781</guid>
      <dc:creator>TriangularLlama</dc:creator>
      <dc:date>2024-10-25T22:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: delete CHAR cols if there's only a single value, no string variation</title>
      <link>https://community.jmp.com/t5/Discussions/delete-CHAR-cols-if-there-s-only-a-single-value-no-string/m-p/808412#M98782</link>
      <description>&lt;P&gt;Here is a simple little script that finds all character columns and then goes from the end of the list to the beginning and if there is only a single value not counting blanks is found then delete the column&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();

charCols = dt &amp;lt;&amp;lt; get column names( string, character );

For( i = N Items( charCols ), i &amp;gt;= 1, i--,
	Summarize( dt, bygroup = by( As Column( charCols[i] ) ) );
	If( bygroup[1] == "",
		Remove From( bygroup, 1, 1 )
	);
	If( N Items( bygroup ) &amp;lt;= 1,
		dt &amp;lt;&amp;lt; delete columns( Column( dt, charCols[i] ) )
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 26 Oct 2024 01:40:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/delete-CHAR-cols-if-there-s-only-a-single-value-no-string/m-p/808412#M98782</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2024-10-26T01:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: delete CHAR cols if there's only a single value, no string variation</title>
      <link>https://community.jmp.com/t5/Discussions/delete-CHAR-cols-if-there-s-only-a-single-value-no-string/m-p/808454#M98790</link>
      <description>&lt;P&gt;Similar idea as Jim (use summarize to take unique values and then remove missing if there is such) but a bit different take: use filter each to find the columns to remove and then remove them all at the same time using delete columns.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Current Data Table();

char_cols = dt &amp;lt;&amp;lt; get column names(Character, String);

cols_to_remove = Filter Each({colname}, char_cols,
	Summarize(dt, uniq = by(Column(dt, colname)));
	Remove From(uniq, Contains(uniq, "")); // to remove missing values from list
	N Items(uniq) == 1;
);


dt &amp;lt;&amp;lt; Delete Columns(cols_to_remove);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 26 Oct 2024 15:36:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/delete-CHAR-cols-if-there-s-only-a-single-value-no-string/m-p/808454#M98790</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-10-26T15:36:06Z</dc:date>
    </item>
    <item>
      <title>Re: delete CHAR cols if there's only a single value, no string variation</title>
      <link>https://community.jmp.com/t5/Discussions/delete-CHAR-cols-if-there-s-only-a-single-value-no-string/m-p/808478#M98794</link>
      <description>&lt;P&gt;One thing to note: both me and Jim remove missing value from our list of unique values. Depending on your data/model/use case you might want to (or have to) consider that as a separate value so take that into account. Both our scripts can take that into account BUT they do need small changes.&lt;/P&gt;</description>
      <pubDate>Sat, 26 Oct 2024 17:14:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/delete-CHAR-cols-if-there-s-only-a-single-value-no-string/m-p/808478#M98794</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-10-26T17:14:20Z</dc:date>
    </item>
  </channel>
</rss>

