<?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: Col Min() &amp;amp; Col Max() for Character columns in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Col-Min-amp-Col-Max-for-Character-columns/m-p/107531#M39160</link>
    <description>&lt;P&gt;The use of Eval(Parse()) methodology, just simply allows one to build a JSL statement(s) into a literal string, and then execute them.&amp;nbsp; I use this on occasion when JMP does not interpret a statement properly.&amp;nbsp; I initially tried the statement in question in this form&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;rr = dt &amp;lt;&amp;lt; get rows where( Column( dt, by ) == testBy );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;JMP did not like this.....or rather, JMP did not interpret this as I thought it would.&amp;nbsp; The statement did work if it was in an explicit form&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;rr = dt &amp;lt;&amp;lt; get rows where( :sex == "F" );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Therefore, by generating that specific line as a literal string and using the Eval(Parse()) combined function, it generates the exact explicit form of the code I want and then executes it&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Eval(Parse(
	"rr = dt &amp;lt;&amp;lt; get rows where( :" || by || " == \!"" || testBy ||"\!" );"
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 22 Jan 2019 17:20:27 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2019-01-22T17:20:27Z</dc:date>
    <item>
      <title>Col Min() &amp; Col Max() for Character columns</title>
      <link>https://community.jmp.com/t5/Discussions/Col-Min-amp-Col-Max-for-Character-columns/m-p/107521#M39152</link>
      <description>&lt;P&gt;I'm interested in a function that would behave analogously to how&amp;nbsp;Col Min()/Col Max() does, including allowing grouping variables; but instead of operating on numeric columns, it would operate on Character columns. For example:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;"Col Min&amp;nbsp;Str( :Data, :Grouping)" would return the alphabetically first&amp;nbsp;entry from :Data, grouped by :Grouping.&lt;/LI&gt;&lt;LI&gt;"Col Max&amp;nbsp;Str(:Data, :Grouping)"&amp;nbsp;would return the alphabetically last&amp;nbsp;entry from :Data, grouped by :Grouping.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Ideas?&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2019 14:28:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Col-Min-amp-Col-Max-for-Character-columns/m-p/107521#M39152</guid>
      <dc:creator>john_madden</dc:creator>
      <dc:date>2019-01-22T14:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: Col Min() &amp; Col Max() for Character columns</title>
      <link>https://community.jmp.com/t5/Discussions/Col-Min-amp-Col-Max-for-Character-columns/m-p/107528#M39157</link>
      <description>&lt;P&gt;I think this provides what you want&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);
dt=open("$SAMPLE_DATA/big class.jmp");

dt &amp;lt;&amp;lt; New Column( "Max Name by Sex",
	Character,
	Nominal,
	Formula(
		Col Max Str = Function( {data, by},
			dt = Current Data Table();
			testBy = Column( dt, by )[Row()];
			Eval(
				Parse(
					"rr = dt &amp;lt;&amp;lt; get rows where( :" || by || " == \!"" || testBy ||
					"\!" );"
				)
			);
			myList = As List( Column( dt, data )[rr] );
			myList = Sort List( myList );
			myList[N Items( myList )];
		);
		result = Col Max Str( "Name", "Sex" );
	)
);

dt &amp;lt;&amp;lt; New Column( "Min Name by Sex",
	Character,
	"Nominal",
	Formula(
		Col Min Str = Function( {data, by},
			dt = Current Data Table();
			testBy = Column( dt, by )[Row()];
			Eval(
				Parse(
					"rr = dt &amp;lt;&amp;lt; get rows where( :" || by || " == \!"" || testBy ||
					"\!" );"
				)
			);
			myList = As List( Column( dt, data )[rr] );
			myList = Sort List( myList );
			myList[1];
		);
		result = Col Min Str( "Name", "Sex" );
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 Jan 2019 16:28:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Col-Min-amp-Col-Max-for-Character-columns/m-p/107528#M39157</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2019-01-22T16:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: Col Min() &amp; Col Max() for Character columns</title>
      <link>https://community.jmp.com/t5/Discussions/Col-Min-amp-Col-Max-for-Character-columns/m-p/107530#M39159</link>
      <description>&lt;P&gt;Jim,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks, this seems to work just right. It does solve my issue.&lt;/P&gt;&lt;P&gt;But can you say a bit about &lt;EM&gt;how&lt;/EM&gt; it works? It looks interesting, and&amp;nbsp;I'm not familiar with the style, in particular what the Eval ( Parse&amp;nbsp;… ) clause is doing.&lt;/P&gt;&lt;P&gt;Cheers, John&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2019 16:56:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Col-Min-amp-Col-Max-for-Character-columns/m-p/107530#M39159</guid>
      <dc:creator>john_madden</dc:creator>
      <dc:date>2019-01-22T16:56:31Z</dc:date>
    </item>
    <item>
      <title>Re: Col Min() &amp; Col Max() for Character columns</title>
      <link>https://community.jmp.com/t5/Discussions/Col-Min-amp-Col-Max-for-Character-columns/m-p/107531#M39160</link>
      <description>&lt;P&gt;The use of Eval(Parse()) methodology, just simply allows one to build a JSL statement(s) into a literal string, and then execute them.&amp;nbsp; I use this on occasion when JMP does not interpret a statement properly.&amp;nbsp; I initially tried the statement in question in this form&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;rr = dt &amp;lt;&amp;lt; get rows where( Column( dt, by ) == testBy );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;JMP did not like this.....or rather, JMP did not interpret this as I thought it would.&amp;nbsp; The statement did work if it was in an explicit form&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;rr = dt &amp;lt;&amp;lt; get rows where( :sex == "F" );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Therefore, by generating that specific line as a literal string and using the Eval(Parse()) combined function, it generates the exact explicit form of the code I want and then executes it&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Eval(Parse(
	"rr = dt &amp;lt;&amp;lt; get rows where( :" || by || " == \!"" || testBy ||"\!" );"
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2019 17:20:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Col-Min-amp-Col-Max-for-Character-columns/m-p/107531#M39160</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2019-01-22T17:20:27Z</dc:date>
    </item>
    <item>
      <title>Re: Col Min() &amp; Col Max() for Character columns</title>
      <link>https://community.jmp.com/t5/Discussions/Col-Min-amp-Col-Max-for-Character-columns/m-p/107533#M39161</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/681"&gt;@john_madden&lt;/a&gt;, your reply got me started about my use of the Eval(Parse()) method.&amp;nbsp; It is a powerful but confusing methodology.&amp;nbsp; So I took a look at the code once again, and by using an As Column() function the whole Eval(Parse()) thing can be removed&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);
dt=open("$SAMPLE_DATA/big class.jmp");

dt &amp;lt;&amp;lt; New Column( "Max Name by Sex",
	Character,
	Nominal,
	Formula(
		Col Max Str = Function( {data, by},
			dt = Current Data Table();
			testBy = Column( dt, by )[Row()];
			rr = dt &amp;lt;&amp;lt; get rows where( as column(dt, by) == testBy  );
			myList = As List( Column( dt, data )[rr] );
			myList = Sort List( myList );
			myList[N Items( myList )];
		);
		result = Col Max Str( "Name", "Sex" );
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 Jan 2019 18:40:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Col-Min-amp-Col-Max-for-Character-columns/m-p/107533#M39161</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2019-01-22T18:40:54Z</dc:date>
    </item>
    <item>
      <title>Re: Col Min() &amp; Col Max() for Character columns</title>
      <link>https://community.jmp.com/t5/Discussions/Col-Min-amp-Col-Max-for-Character-columns/m-p/217087#M43389</link>
      <description>Jim,&lt;BR /&gt;Can be this jsl more generic?&lt;BR /&gt;for example for the table below&lt;BR /&gt;&lt;BR /&gt;Try Why&lt;BR /&gt;A 1A&lt;BR /&gt;A 2C&lt;BR /&gt;A 2D&lt;BR /&gt;B 3B&lt;BR /&gt;B 2F&lt;BR /&gt;C 1S&lt;BR /&gt;C 1W&lt;BR /&gt;C 1R&lt;BR /&gt;&lt;BR /&gt;I want to get the max of "Why" per Try i.e.&lt;BR /&gt;A 2D&lt;BR /&gt;B 3B&lt;BR /&gt;C 1W&lt;BR /&gt;</description>
      <pubDate>Thu, 11 Jul 2019 07:36:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Col-Min-amp-Col-Max-for-Character-columns/m-p/217087#M43389</guid>
      <dc:creator>Isak_JMP</dc:creator>
      <dc:date>2019-07-11T07:36:00Z</dc:date>
    </item>
    <item>
      <title>Re: Col Min() &amp; Col Max() for Character columns</title>
      <link>https://community.jmp.com/t5/Discussions/Col-Min-amp-Col-Max-for-Character-columns/m-p/217102#M43392</link>
      <description>&lt;P&gt;The Col Max Str() function is generic.&amp;nbsp; It works on whatever character data is passed to it.&amp;nbsp; Below is it's usage on your sample data table&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);
dt=New Table( "Untitled 2",
	Add Rows( 8 ),
	New Column( "Try",
		Character,
		"Nominal",
		Set Values( {"A", "A", "A", "B", "B", "C", "C", "C"} )
	),
	New Column( "Why",
		Character,
		"Nominal",
		Set Values( {"1A", "2C", "2D", "3B", "2F", "1S", "1W", "1R"} )
	)
);

dt &amp;lt;&amp;lt; New Column( "Max Why by Try",
	Character,
	Nominal,
	Formula(
		Col Max Str = Function( {data, by},
			dt = Current Data Table();
			testBy = Column( dt, by )[Row()];
			rr = dt &amp;lt;&amp;lt; get rows where( as column(dt, by) == testBy  );
			myList = As List( Column( dt, data )[rr] );
			myList = Sort List( myList );
			myList[N Items( myList )];
		);
		result = Col Max Str( "Why", "try" );
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Jul 2019 10:26:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Col-Min-amp-Col-Max-for-Character-columns/m-p/217102#M43392</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2019-07-11T10:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: Col Min() &amp; Col Max() for Character columns</title>
      <link>https://community.jmp.com/t5/Discussions/Col-Min-amp-Col-Max-for-Character-columns/m-p/217135#M43400</link>
      <description>&lt;P&gt;Here's another solution that uses one of my favorite properties of math.&amp;nbsp;&amp;nbsp;&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");
l = :name &amp;lt;&amp;lt; Get Values;

r = rank(l);

rr = rank(r);
dt &amp;lt;&amp;lt; new Column("Order", &amp;lt;&amp;lt;Set Values(rr));

dt &amp;lt;&amp;lt; new Column("ColMin", Formula(ColMin(:Order, :age)));
dt &amp;lt;&amp;lt; new Column("ColMax", Formula(ColMax(:Order, :age)));

dt &amp;lt;&amp;lt; New Column("Col Character Min", character, &amp;lt;&amp;lt;Set Each Value(l[r][:ColMin]));
dt &amp;lt;&amp;lt; New Column("Col Character Max", character, &amp;lt;&amp;lt;Set Each Value(l[r][:ColMax]));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The way it works is all based on rank.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Rank of a list will give the order required to subset the original list to get an ordered list.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;l = {"B", "D", "C", "A"};
r = rank(l);
// r = [4, 1, 3, 2]
// l[r] = {"A", "B", "C", "D"}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The cool think is if you tank a rank() of a rank() it will give you the order required to bring it back to the original list when used to subscript the sorted list.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;rr = rank(r);
// rr = [2, 4, 3, 1]
// l[r][rr] = {"B", "D", "C", "A"}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hope this works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 14:57:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Col-Min-amp-Col-Max-for-Character-columns/m-p/217135#M43400</guid>
      <dc:creator>vince_faller</dc:creator>
      <dc:date>2019-07-11T14:57:20Z</dc:date>
    </item>
    <item>
      <title>Re: Col Min() &amp; Col Max() for Character columns</title>
      <link>https://community.jmp.com/t5/Discussions/Col-Min-amp-Col-Max-for-Character-columns/m-p/217139#M43402</link>
      <description>&lt;P&gt;Both repliers-&amp;nbsp; thanks -&amp;nbsp; I'll&amp;nbsp; validate&amp;nbsp; this&amp;nbsp; solution and&amp;nbsp; reply&amp;nbsp; you&lt;/P&gt;&lt;P&gt;The&amp;nbsp; Question is if it&amp;nbsp; can&amp;nbsp; work&amp;nbsp; on ~70k&amp;nbsp; rows&amp;nbsp; and how long?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BTW, I'm&amp;nbsp; using&amp;nbsp; very, very&amp;nbsp; strong (RAM, SSD)&amp;nbsp; machine on&amp;nbsp; AWS instance ...&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 15:21:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Col-Min-amp-Col-Max-for-Character-columns/m-p/217139#M43402</guid>
      <dc:creator>Isak_JMP</dc:creator>
      <dc:date>2019-07-11T15:21:18Z</dc:date>
    </item>
  </channel>
</rss>

