<?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 JSL: get unique values of a data table column in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JSL-get-unique-values-of-a-data-table-column/m-p/985#M985</link>
    <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;I currently use the summary command to get unique values of a data table column, which in my opinion is too complicated for that simple task. I think there has to be a simpler command that works on a data table column or a vector, but I cannot find one. Am I right?&lt;BR /&gt;&lt;BR /&gt;My current code looks like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// sample data set:
dt = New Table( "dt" );
dt:"Column 1" &amp;lt;&amp;lt; setvalues( [1, 1, 2, 7, 7, 4, 5, 1, 5] );

// use summary to get unique values:
dt_sum = dt &amp;lt;&amp;lt; summary( group( :Column 1 ), N, outputtablename( "dt_sum" ) );
unique_values = dt_sum:"Column 1" &amp;lt;&amp;lt; getvalues;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Dahla&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 26 Jun 2019 17:11:44 GMT</pubDate>
    <dc:creator />
    <dc:date>2019-06-26T17:11:44Z</dc:date>
    <item>
      <title>JSL: get unique values of a data table column</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-get-unique-values-of-a-data-table-column/m-p/985#M985</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;I currently use the summary command to get unique values of a data table column, which in my opinion is too complicated for that simple task. I think there has to be a simpler command that works on a data table column or a vector, but I cannot find one. Am I right?&lt;BR /&gt;&lt;BR /&gt;My current code looks like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// sample data set:
dt = New Table( "dt" );
dt:"Column 1" &amp;lt;&amp;lt; setvalues( [1, 1, 2, 7, 7, 4, 5, 1, 5] );

// use summary to get unique values:
dt_sum = dt &amp;lt;&amp;lt; summary( group( :Column 1 ), N, outputtablename( "dt_sum" ) );
unique_values = dt_sum:"Column 1" &amp;lt;&amp;lt; getvalues;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Dahla&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2019 17:11:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-get-unique-values-of-a-data-table-column/m-p/985#M985</guid>
      <dc:creator />
      <dc:date>2019-06-26T17:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: JSL: get unique values</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-get-unique-values-of-a-data-table-column/m-p/987#M987</link>
      <description>Thanks for your help! Summarize works fine!&lt;BR /&gt;&lt;BR /&gt;Dahla</description>
      <pubDate>Fri, 04 Dec 2009 11:58:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-get-unique-values-of-a-data-table-column/m-p/987#M987</guid>
      <dc:creator />
      <dc:date>2009-12-04T11:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: JSL: get unique values</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-get-unique-values-of-a-data-table-column/m-p/44644#M25566</link>
      <description>&lt;P&gt;Also:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;unique values = Associative Array( col ) &amp;lt;&amp;lt; Get Keys&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Sep 2017 18:05:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-get-unique-values-of-a-data-table-column/m-p/44644#M25566</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2017-09-15T18:05:59Z</dc:date>
    </item>
    <item>
      <title>Re: JSL: get unique values</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-get-unique-values-of-a-data-table-column/m-p/44649#M25568</link>
      <description>Summarize works well if you want to keep the data in a data table format .&lt;BR /&gt;&lt;BR /&gt;Associative Array as suggested by &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/5358"&gt;@Mark_Bailey&lt;/a&gt; works well if you want to work in lists .</description>
      <pubDate>Fri, 15 Sep 2017 19:50:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-get-unique-values-of-a-data-table-column/m-p/44649#M25568</guid>
      <dc:creator>uday_guntupalli</dc:creator>
      <dc:date>2017-09-15T19:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: JSL: get unique values of a data table column</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-get-unique-values-of-a-data-table-column/m-p/45597#M26057</link>
      <description>&lt;P&gt;Try summar&lt;STRONG&gt;ize&lt;/STRONG&gt;...&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Summarize can do more...see the scripting docs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A couple of downsides.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Even though the column summarized may be numeric, the list returned contains character values.&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;Related to 1, the precision of numeric values gets truncated based on the column width.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// sample data set:
dt = newtable("dt");
dt:"Column 1" &amp;lt;&amp;lt; setvalues([1, 1, 2, 7, 7, 4, 5, 1, 5]); &amp;nbsp;summarize(unique_values=by(Column 1));
show(unique_values)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But ... here's a workaround to the downsides:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;summarize(unique_values=by(Column 1), unique_numeric_values=(max(Column 1)));
show(unique_values, unique_numeric_values) &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 14:09:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-get-unique-values-of-a-data-table-column/m-p/45597#M26057</guid>
      <dc:creator>ms</dc:creator>
      <dc:date>2017-10-06T14:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: JSL: get unique values of a data table column</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-get-unique-values-of-a-data-table-column/m-p/190693#M40956</link>
      <description>&lt;P&gt;Proposing a Summary solution for JMP users on the beginner (my) side of the spectrum.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;In this example we want a list of unique finished goods from a list of customer orders.&amp;nbsp;I won't link the table and I'll give the Output Table a name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On the original data table go to Tables -&amp;gt; Summary&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JMP Community UniqueList1.png" style="width: 652px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/16715iB14DA675CE991B72/image-size/large?v=v2&amp;amp;px=999" role="button" title="JMP Community UniqueList1.png" alt="JMP Community UniqueList1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Drag Finished Good from the select columns over to Group on the right.&lt;BR /&gt;Give the Output table a name, in this case UniqueFG.&lt;/P&gt;&lt;P&gt;Uncheck Link to original data table.&lt;/P&gt;&lt;P&gt;Click Action OK.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JMP Community UniqueList2.png" style="width: 391px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/16714i22B5645CFD32BA2A/image-size/large?v=v2&amp;amp;px=999" role="button" title="JMP Community UniqueList2.png" alt="JMP Community UniqueList2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The resulting data table is a list of all unique FG and the count of rows.&lt;BR /&gt;Click edit Source script.&lt;/P&gt;&lt;P&gt;It will look something like this.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Data Table( "Test" ) &amp;lt;&amp;lt;
Summary(
	Group( :Finished Good ),
	Freq( "None" ),
	Weight( "None" ),
	Link to original data table( 0 ),
	output table name( "UniqueFG" )
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Copy that code.&lt;/P&gt;&lt;P&gt;Create a new script in the original data table and paste in the code.&amp;nbsp; I've modified the code slightly to make it more flexible/scalable and commented in some notes below.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//Creates a list of unique FG #s to feed to SAP to get unit weights and carton quantities
Names Default to Here(1);
dt = current data table();

dt &amp;lt;&amp;lt;
Summary(
	Group( :Finished Good ),  //this is the column from which you want unique values
	Freq( "None" ),
	Weight( "None" ),
	Link to original data table( 0 ), //this turns off table linking
	output table name( "UniqueFG" )  // this is the name of the new datatable
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Save.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Feel free to let me know if this is/isn't a good approach or code structure.&amp;nbsp; Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2019 19:48:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-get-unique-values-of-a-data-table-column/m-p/190693#M40956</guid>
      <dc:creator>BSwid</dc:creator>
      <dc:date>2019-04-01T19:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: JSL: get unique values</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-get-unique-values-of-a-data-table-column/m-p/214758#M42939</link>
      <description>&lt;P&gt;Thanks for this wonderful and short solution &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/5358"&gt;@Mark_Bailey&lt;/a&gt; .&lt;/P&gt;&lt;P&gt;It most often works but not in the following case:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;values = {0.111, 0.222, 0.333}; // This is actually something like: values = Column(SomeList[1]) &amp;lt;&amp;lt; Get Keys
N Items(Associative Array(values)) // gives 1&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;JMP ignores the decimal places when creating the associative array. (Using JMP 12)&lt;/P&gt;&lt;P&gt;How can I fix that using accociative arrays so that N Items returns 3 instead of 1?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2019 06:19:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-get-unique-values-of-a-data-table-column/m-p/214758#M42939</guid>
      <dc:creator>Robbb</dc:creator>
      <dc:date>2019-06-26T06:19:48Z</dc:date>
    </item>
    <item>
      <title>Re: JSL: get unique values</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-get-unique-values-of-a-data-table-column/m-p/214819#M42950</link>
      <description>You could try Summarize(), and then simply loop through the list that is returned and change the string values back to numeric by using the num() function.&lt;BR /&gt;You could create a new column where you use a formula&lt;BR /&gt;     :variable * 100&lt;BR /&gt;and then convert the data as it comes out of the Associative Array&lt;BR /&gt;You could create a new column, converting the values to character</description>
      <pubDate>Wed, 26 Jun 2019 14:49:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-get-unique-values-of-a-data-table-column/m-p/214819#M42950</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2019-06-26T14:49:04Z</dc:date>
    </item>
    <item>
      <title>Re: JSL: get unique values</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-get-unique-values-of-a-data-table-column/m-p/214874#M42960</link>
      <description>&lt;P&gt;Study this example:&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 = Open( "$SAMPLE_DATA/Big Class.jmp" );

values = dt:age &amp;lt;&amp;lt; Get Values;

array = Associative Array( values );

array &amp;lt;&amp;lt; Get Keys;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Jun 2019 16:59:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-get-unique-values-of-a-data-table-column/m-p/214874#M42960</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2019-06-26T16:59:05Z</dc:date>
    </item>
    <item>
      <title>Re: JSL: get unique values</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-get-unique-values-of-a-data-table-column/m-p/435967#M68509</link>
      <description>&lt;P&gt;Hi, what would be the approach for using the keys in the array for selecting or filtering rows with the same keys, but in a different JMP table. I have two tables. One of them maps sample IDs for chemical testing to different factor settings (temperature, time, study nr., etc.). I am successfully getting the sample IDs in an array. (Sorry, I'm a total newbie to this.)&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;smplID = Associative array(:sampleid) &amp;lt;&amp;lt; Get Keys;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Now I want to use these keys to select rows in the second table (where my responses are), invert the row selection and delete the rows. Perhaps the solution below, &lt;A href="https://community.jmp.com/t5/Discussions/How-to-Identify-Unique-Values-in-a-Column-from-a-Data-Table-to-a/td-p/381364" target="_self"&gt;as described here,&lt;/A&gt; is better suited to start with&lt;SPAN style="font-family: inherit;"&gt;?&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;Summarize(dt, smpleID = by(:sampleid));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Or maybe &lt;A href="https://community.jmp.com/t5/JSL-Cookbook/Get-a-list-of-the-unique-values-in-a-column-matrix-or-list/ta-p/51256" target="_self"&gt;this approach&lt;/A&gt; is preferable?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;dt &amp;lt;&amp;lt; Summary (Group ( :sampleid ), Frequ( "None" ), Weight( "None" );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Anyway, what I really want to know is, how I may use any of these approaches to effectively cleanse a data table for rows I don't need, before I proceed any further with data analysis.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit: discussed &amp;amp; solved &lt;A href="https://community.jmp.com/t5/Discussions/Get-unique-column-values-amp-use-them-for-filtering-cleaning-up/m-p/436339#M68554" target="_self"&gt;here&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Nov 2021 15:07:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-get-unique-values-of-a-data-table-column/m-p/435967#M68509</guid>
      <dc:creator>Ressel</dc:creator>
      <dc:date>2021-11-16T15:07:37Z</dc:date>
    </item>
  </channel>
</rss>

