<?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: application scripting... Group by , variable in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/application-scripting-Group-by-variable/m-p/56709#M31817</link>
    <description>&lt;P&gt;Jim is correct.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Without Names Default To Here(1), all variables are global. The JMP Scripting Guide states&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;"When a global variable and a column have the same name, ...&amp;nbsp;In this situation, you must scope the column name."&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;In fact, when I run the script, I get the error&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;FONT color="#0000FF"&gt;Cannot set value for the column 'age' because the row number (-1) is not valid.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since it is not ::age, JMP thinks the statement age=13 is trying to assign values to the column named age.&amp;nbsp; Names Default To Here(1) makes the variable "age" local and resolves this conflict. However,&amp;nbsp; I strongly recommend that you use Names Default to Here(1)&amp;nbsp; &lt;EM&gt;&lt;U&gt;&lt;STRONG&gt;and&lt;/STRONG&gt;&lt;/U&gt;&lt;/EM&gt; use a different name for user input like, _age or usr_val.&amp;nbsp; I believe name collisions (conflicts, a.k.a. scoping) is the second highest occuring scripting error after syntax and typos.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The script below is a slight modification of&amp;nbsp;Jim's:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;_age is assigned a value&lt;/LI&gt;&lt;LI&gt;an alternative to Fit Where().&amp;nbsp; Selecting the values to be used and then using Group By() will provide the name for each Group By value.&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);

dt=open("$SAMPLE_DATA/big class.jmp");

_age=13;

biv =  dt &amp;lt;&amp;lt; Bivariate(
	Y( :weight),
	X( :height),
	Show Points( 0 ),
	where(:age==12 | :age==_age),
	Group By(:age),
	Fit Each Value( {Report(0)}),
	By(:sex)
);

biv &amp;lt;&amp;lt; ( Curve[1] &amp;lt;&amp;lt; Line Color ( {0, 0, 255    } ) );
biv &amp;lt;&amp;lt; ( Curve[2] &amp;lt;&amp;lt; Line Color ( {213, 72, 255 } ) );


&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 09 May 2018 07:34:34 GMT</pubDate>
    <dc:creator>gzmorgan0</dc:creator>
    <dc:date>2018-05-09T07:34:34Z</dc:date>
    <item>
      <title>application scripting... Group by , variable</title>
      <link>https://community.jmp.com/t5/Discussions/application-scripting-Group-by-variable/m-p/56591#M31812</link>
      <description>&lt;P&gt;I am creating an application which allows the user to select a few options before running a script which involves a few SQL queries and then making some graphs... nothing too crazy.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A radio button control is used to set the value of a variable named "type"..&amp;nbsp; I want one of the "fit where" options for a bivariate graph to be the contents of this variable...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Bivariate(
Y( :Current),
X( :Voltage),
Show Points( 0 ),
Fit Where(
:type == "cell",
Fit Each Value( {Report( 0 ), Line Color( {0, 0, 255} ), Report( 0 )} )
),
Fit Where(
:type == type,&amp;nbsp; //this is troublesome line... the graph is generated but not quite right.
Fit Each Value( {Report( 0 ), Line Color( {213, 72, 87} ), Report( 0 )} )
),
By( :CellID)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The graph generates correctly, but the annoying thing is&amp;nbsp;the resulting graph says "fit each value type == type".&amp;nbsp; How can I get it to display the contents of the variable which was used instead of it's name??&amp;nbsp; I've tried a few options already including "eval(type)".&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 398px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/10659iCD45069192D4635C/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 May 2018 23:09:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/application-scripting-Group-by-variable/m-p/56591#M31812</guid>
      <dc:creator>pjr1121</dc:creator>
      <dc:date>2018-05-08T23:09:51Z</dc:date>
    </item>
    <item>
      <title>Re: application scripting... Group by , variable</title>
      <link>https://community.jmp.com/t5/Discussions/application-scripting-Group-by-variable/m-p/56594#M31815</link>
      <description>&lt;P&gt;The issue appears to be a scoping problem.&amp;nbsp; I was not able to run your script successfully until I added&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here( 1 );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is your script with the column names pointing to the Big Class data table.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);

dt=open("$SAMPLE_DATA/big class.jmp");

age=13;

Bivariate(
Y( :weight),
X( :height),
Show Points( 0 ),
Fit Where(
:age == 12,
Fit Each Value( {Report( 0 ), Line Color( {0, 0, 255} ), Report( 0 )} )
),
Fit Where(
:age == age,  //this is troublesome line... the graph is generated but not quite right.
Fit Each Value( {Report( 0 ), Line Color( {213, 72, 87} ), Report( 0 )} )
),
By( :sex)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 May 2018 03:42:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/application-scripting-Group-by-variable/m-p/56594#M31815</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-05-09T03:42:43Z</dc:date>
    </item>
    <item>
      <title>Re: application scripting... Group by , variable</title>
      <link>https://community.jmp.com/t5/Discussions/application-scripting-Group-by-variable/m-p/56709#M31817</link>
      <description>&lt;P&gt;Jim is correct.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Without Names Default To Here(1), all variables are global. The JMP Scripting Guide states&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;"When a global variable and a column have the same name, ...&amp;nbsp;In this situation, you must scope the column name."&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;In fact, when I run the script, I get the error&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;FONT color="#0000FF"&gt;Cannot set value for the column 'age' because the row number (-1) is not valid.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since it is not ::age, JMP thinks the statement age=13 is trying to assign values to the column named age.&amp;nbsp; Names Default To Here(1) makes the variable "age" local and resolves this conflict. However,&amp;nbsp; I strongly recommend that you use Names Default to Here(1)&amp;nbsp; &lt;EM&gt;&lt;U&gt;&lt;STRONG&gt;and&lt;/STRONG&gt;&lt;/U&gt;&lt;/EM&gt; use a different name for user input like, _age or usr_val.&amp;nbsp; I believe name collisions (conflicts, a.k.a. scoping) is the second highest occuring scripting error after syntax and typos.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The script below is a slight modification of&amp;nbsp;Jim's:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;_age is assigned a value&lt;/LI&gt;&lt;LI&gt;an alternative to Fit Where().&amp;nbsp; Selecting the values to be used and then using Group By() will provide the name for each Group By value.&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);

dt=open("$SAMPLE_DATA/big class.jmp");

_age=13;

biv =  dt &amp;lt;&amp;lt; Bivariate(
	Y( :weight),
	X( :height),
	Show Points( 0 ),
	where(:age==12 | :age==_age),
	Group By(:age),
	Fit Each Value( {Report(0)}),
	By(:sex)
);

biv &amp;lt;&amp;lt; ( Curve[1] &amp;lt;&amp;lt; Line Color ( {0, 0, 255    } ) );
biv &amp;lt;&amp;lt; ( Curve[2] &amp;lt;&amp;lt; Line Color ( {213, 72, 255 } ) );


&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 May 2018 07:34:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/application-scripting-Group-by-variable/m-p/56709#M31817</guid>
      <dc:creator>gzmorgan0</dc:creator>
      <dc:date>2018-05-09T07:34:34Z</dc:date>
    </item>
    <item>
      <title>Re: application scripting... Group by , variable</title>
      <link>https://community.jmp.com/t5/Discussions/application-scripting-Group-by-variable/m-p/56725#M31826</link>
      <description>&lt;P&gt;Thank you very much for the quick responses. i forgot to copy it into my example but the very beginning of my script started with "names default to here(1);"&amp;nbsp; Don' think it matters where that command apperas within the script, so long as it is before the relevent function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried Jim's code first and it produced the same problem as my original script.&amp;nbsp; The value 13 was not dispayed below the graph, but instead "age==age".&amp;nbsp; note: i'm running JMP 12&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/10686i5E4D6027B15BA7A3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;As i'm using a variable name which does not match a column in my tables, i don't think i'm running into the issue of JMP trying to assign the column values as mentioned by gzmorgan0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The approach of using 'group by' instead of 'fit where' did the trick.&amp;nbsp; Since I copied this script from a bivariate created via "group by" menu options, i'm not confused as to why it used 'fit where' instead.&amp;nbsp; But that's another problem for another day.&amp;nbsp; Thanks for the hel .&lt;/P&gt;</description>
      <pubDate>Wed, 09 May 2018 14:14:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/application-scripting-Group-by-variable/m-p/56725#M31826</guid>
      <dc:creator>pjr1121</dc:creator>
      <dc:date>2018-05-09T14:14:00Z</dc:date>
    </item>
  </channel>
</rss>

