<?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: JSL: DT&amp;lt;&amp;lt;SelectWhere Behavior in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JSL-DT-lt-lt-SelectWhere-Behavior/m-p/35862#M21159</link>
    <description>&lt;P&gt;I use the As Column most of the time. &amp;nbsp;It works with either a string name or column reference:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;dt = Open("$SAMPLE_DATA/Big Class.jmp");

// column name
col = "height"; 
dt &amp;lt;&amp;lt; Select Where( AsColumn(col) &amp;lt;60 );

Wait(2);
dt  &amp;lt;&amp;lt; Clear Row States;

// column reference
col = Column(dt,"height");
dt &amp;lt;&amp;lt; Select Where( AsColumn(col) &amp;gt; 65 );&lt;/PRE&gt;
&lt;P&gt;If I feel the need to embed an actual text string into :Name on the fly then I use the other method shown, although I use other syntax that I find easier to deal with:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open("$SAMPLE_DATA/Big Class.jmp");
colName = "height";
Eval(Parse(EvalInsert("\[ 
	dt &amp;lt;&amp;lt; Select Where( :Name("^colName^") &amp;gt; 65 );
]\")));&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 16 Feb 2017 10:15:37 GMT</pubDate>
    <dc:creator>David_Burnham</dc:creator>
    <dc:date>2017-02-16T10:15:37Z</dc:date>
    <item>
      <title>JSL: DT&lt;&lt;SelectWhere Behavior</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-DT-lt-lt-SelectWhere-Behavior/m-p/35823#M21131</link>
      <description>&lt;P&gt;Normal "SelectWhere" usage appears to be as follows:&lt;/P&gt;&lt;PRE&gt;dt&amp;lt;&amp;lt;SelectWhere(:ExampleColumnName &amp;gt; 5);&lt;/PRE&gt;&lt;P&gt;And this works fine. What I have difficulty with is when I need more flexiblity in what the ":ExampleColumnName" is going to be.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, if I save a new column of Studentized Residuals in a Fit Model, it will create a column called something like "Studentized Resid Log(CFU/mL) By Condition". Let's say I want to select anything above 3 or below -3. Due to the column's name, I would need to use:&lt;/P&gt;&lt;PRE&gt;dt&amp;lt;&amp;lt;SelectWhere(:Name("Studentized Resid Log(CFU/mL) By Condition")&amp;lt;-3 | :Name("Studentized Resid Log(CFU/mL) By Condition")&amp;gt;3);&lt;/PRE&gt;&lt;P&gt;This is fine most of the time, but not always. Having to have the fully written out string&amp;nbsp;within :Name()&amp;nbsp;isn't really ideal -- for example, if the plan is to make a function usable for a variety of Fit Models that will each&amp;nbsp;produce different Studentized Residual column names, it isn't efficient to&amp;nbsp;write a unique "SelectWhere" for every possible model (especially if you can't always&amp;nbsp;anticipate what model the user will choose).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I would like to work is one/both of the following:&lt;/P&gt;&lt;PRE&gt;//Option 1
colName = ""Studentized Resid Log(CFU/mL) By Condition";
dt&amp;lt;&amp;lt;SelectWhere(:Name(colName)&amp;lt;-3 | ::Name(colName)&amp;gt;3);

//Option 2
colRef = Column(dt, colName);
dt&amp;lt;&amp;lt;SelectWhere( colRef &amp;lt;-3 | colRef &amp;gt;3 );&lt;/PRE&gt;&lt;P&gt;Option 1 returns a "Name argument must be quoted string" error when the SelectWhere function is run. Seems like :Name() requires a fully written out string, and a reference to one is unacceptable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Option 2 returns no errors, but nothing will be selected. SelectWhere doesn't seem to treat column reference variables&amp;nbsp;like explicitly typed out ":XXXX" references.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My current workaround is not great: after Fit Model creates new column, rename the very last column on the table to something simple and unique (like "StdResid") that can be directly used in the "normal usage" of SelectWhere (e.g., ":StdResid").&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Am I missing something obvious here that would make my life easier?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, is there any&amp;nbsp;way to get Option 1 and/or Option 2 to work?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 13:53:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-DT-lt-lt-SelectWhere-Behavior/m-p/35823#M21131</guid>
      <dc:creator>ABI</dc:creator>
      <dc:date>2017-02-15T13:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: JSL: DT&lt;&lt;SelectWhere Behavior</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-DT-lt-lt-SelectWhere-Behavior/m-p/35833#M21136</link>
      <description>&lt;P&gt;Here is an approach that I use, when nothing else seems to be getting me the results I need:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Eval(parse("dt &amp;lt;&amp;lt; select where(" || ":Name(\!"" || Char( Column( dt, 1 ) &amp;lt;&amp;lt; get name ) || 
"\!")&amp;lt; -3 | :Name(\!"" || Char( Column( dt, 1 ) &amp;lt;&amp;lt; get name ) || "\!")  &amp;gt; 3);"));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Feb 2017 14:56:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-DT-lt-lt-SelectWhere-Behavior/m-p/35833#M21136</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-02-15T14:56:52Z</dc:date>
    </item>
    <item>
      <title>Re: JSL: DT&lt;&lt;SelectWhere Behavior</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-DT-lt-lt-SelectWhere-Behavior/m-p/35835#M21138</link>
      <description>&lt;P&gt;JSL and column names are confusing, especially when you're trying to use GET ROWS WHERE or SELECT WHERE. &amp;nbsp;I tend to use the construct as column(dt, "column-name").&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This will work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = New Table( "Test Table", Add Rows( 9 ),
	New Column( "Studentized Resid Log(CFU/mL) By Condition",
		Numeric, Continuous, Format( "Best", 12 ),
		Set Values( [-4, -3, -2, -1, 0, 1, 2, 3, 4] ) )
);

colName = "Studentized Resid Log(CFU/mL) By Condition";

dt &amp;lt;&amp;lt; Select Where(as column(dt, colName) &amp;lt; -3 | as column(dt, colName) &amp;gt; 3);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Feb 2017 16:16:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-DT-lt-lt-SelectWhere-Behavior/m-p/35835#M21138</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2017-02-15T16:16:13Z</dc:date>
    </item>
    <item>
      <title>Re: JSL: DT&lt;&lt;SelectWhere Behavior</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-DT-lt-lt-SelectWhere-Behavior/m-p/35847#M21147</link>
      <description>&lt;P&gt;Both great ideas, thanks. I had been trying to use Column(dt, colName) before and didn't know that AsColumn() existed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would still love to see the functionality from Option 1 and Option 2 implemented some day. What's the best way&amp;nbsp;to ask for&amp;nbsp;this?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 19:29:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-DT-lt-lt-SelectWhere-Behavior/m-p/35847#M21147</guid>
      <dc:creator>ABI</dc:creator>
      <dc:date>2017-02-15T19:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: JSL: DT&lt;&lt;SelectWhere Behavior</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-DT-lt-lt-SelectWhere-Behavior/m-p/35852#M21151</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think the important piece to understand is what each returns:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The :Name() syntax is a special parser that only accepts a string argument, as you saw. &amp;nbsp;This makes it quite inflexible for scripting.&lt;/LI&gt;
&lt;LI&gt;The Column() function is returning a reference to the column as a whole. &amp;nbsp;Select Where() performs its comparisons on each row. &amp;nbsp;Adding a Row() subscript &amp;nbsp;(or just []) to the Column() function will instruct JMP to look at the column on the current row, whatever that is while the Select Where() is performing its comparison.&amp;nbsp;&lt;/LI&gt;
&lt;/UL&gt;
&lt;PRE&gt;colName = "Studentized Resid Log(CFU/mL) By Condition";&lt;BR /&gt;&lt;BR /&gt;dt &amp;lt;&amp;lt; Select Where( Column( colName )[] &amp;lt; -3 | Column( colName )[] &amp;gt; 3 );&lt;/PRE&gt;
&lt;UL&gt;
&lt;LI&gt;The As Column() function returns a reference to the value in the specified column on the current row. &amp;nbsp;In the context of a Select Where(), the current row is being controlled by the Select Where(). &amp;nbsp;That is why the Row() subscript is not necessary for&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/4550"&gt;@pmroz&lt;/a&gt;'s example. &amp;nbsp;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Hope that&amp;nbsp;helps!&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 20:59:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-DT-lt-lt-SelectWhere-Behavior/m-p/35852#M21151</guid>
      <dc:creator>Wendy_Murphrey</dc:creator>
      <dc:date>2017-02-15T20:59:27Z</dc:date>
    </item>
    <item>
      <title>Re: JSL: DT&lt;&lt;SelectWhere Behavior</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-DT-lt-lt-SelectWhere-Behavior/m-p/35862#M21159</link>
      <description>&lt;P&gt;I use the As Column most of the time. &amp;nbsp;It works with either a string name or column reference:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;dt = Open("$SAMPLE_DATA/Big Class.jmp");

// column name
col = "height"; 
dt &amp;lt;&amp;lt; Select Where( AsColumn(col) &amp;lt;60 );

Wait(2);
dt  &amp;lt;&amp;lt; Clear Row States;

// column reference
col = Column(dt,"height");
dt &amp;lt;&amp;lt; Select Where( AsColumn(col) &amp;gt; 65 );&lt;/PRE&gt;
&lt;P&gt;If I feel the need to embed an actual text string into :Name on the fly then I use the other method shown, although I use other syntax that I find easier to deal with:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open("$SAMPLE_DATA/Big Class.jmp");
colName = "height";
Eval(Parse(EvalInsert("\[ 
	dt &amp;lt;&amp;lt; Select Where( :Name("^colName^") &amp;gt; 65 );
]\")));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Feb 2017 10:15:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-DT-lt-lt-SelectWhere-Behavior/m-p/35862#M21159</guid>
      <dc:creator>David_Burnham</dc:creator>
      <dc:date>2017-02-16T10:15:37Z</dc:date>
    </item>
  </channel>
</rss>

