<?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: Can't &amp;quot;evaluate&amp;quot; an expression in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Can-t-quot-evaluate-quot-an-expression/m-p/40166#M23510</link>
    <description>Hi Jim,&lt;BR /&gt;&lt;BR /&gt;Your solution works indeed! Thanks very much.&lt;BR /&gt;I'm contacting support.</description>
    <pubDate>Fri, 09 Jun 2017 12:00:07 GMT</pubDate>
    <dc:creator>matlag</dc:creator>
    <dc:date>2017-06-09T12:00:07Z</dc:date>
    <item>
      <title>Can't "evaluate" an expression</title>
      <link>https://community.jmp.com/t5/Discussions/Can-t-quot-evaluate-quot-an-expression/m-p/40115#M23485</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm once again struggling with a script...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This one builds an expression. It looks ok.&lt;/P&gt;&lt;P&gt;I can even copy and paste it from the log file back to the script window, and if I do so, it executes correctly with expected output.&lt;/P&gt;&lt;P&gt;But I tried Eval(), Eval Expr(), Eval(Eval Expr()), Eval(Parse())... well that last one with even less hope than the others, but bottom line is... I just can't make it work!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
ParamsList = {
	{"P1", "Parameter 1"},
	{"P2", "Parameter 2"}
};

analysis = Expr(Analysis Column());

For (i=1, i&amp;lt;= Length(ParamsList), i++,
	Insert Into(
		analysis,
		Substitute(
			Expr(Transform Column("__Desc__", Formula(__Parameter__))),
			"__Desc__", ParamsList[i][2]||" Median",
			Expr(__Parameter__), Parse(":"||ParamsList[i][1]||"_Q50")
		)
	);
);

addRowExpr = Expr(Row Table());
Insert Into(addRowExpr, Eval Expr(analysis));
Insert Into(addRowExpr, Expr(Statistics(Median)));

addTabExpr = Expr(Add Table(Column Table(Grouping Columns(:Source))));
Insert Into(addTabExpr, Eval Expr(addRowExpr));

tabExpr = Expr(Tabulate(Set Format(Uniform Format(10,2))));
Insert Into(tabExpr, Eval Expr(addTabExpr));

show(tabExpr);

dtParams = Eval(Eval Expr(tabExpr));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I attach a "Test.jmp" file on which you can try.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output of the "show" command is:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;tabExpr = Tabulate(Set Format(Uniform Format(10, 2)), Add Table(Column Table(Grouping Columns(:Source)), Row Table(Analysis Column(Transform Column("Parameter 1 Median", Formula(:P1_Q50)), Transform Column("Parameter 2 Median", Formula(:P2_Q50))), Statistics(Median))));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And as said: if I copy-paste it back to the script window to execute that output, I get what I want!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, how do I "evaluate" that expression?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2017 15:50:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Can-t-quot-evaluate-quot-an-expression/m-p/40115#M23485</guid>
      <dc:creator>matlag</dc:creator>
      <dc:date>2017-06-08T15:50:54Z</dc:date>
    </item>
    <item>
      <title>Re: Can't "evaluate" an expression</title>
      <link>https://community.jmp.com/t5/Discussions/Can-t-quot-evaluate-quot-an-expression/m-p/40126#M23493</link>
      <description>&lt;P&gt;Just running "tabExpr" will evaluate the expression.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;tabulateObject = tabExpr;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2017 17:29:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Can-t-quot-evaluate-quot-an-expression/m-p/40126#M23493</guid>
      <dc:creator>Justin_Chilton</dc:creator>
      <dc:date>2017-06-08T17:29:04Z</dc:date>
    </item>
    <item>
      <title>Re: Can't "evaluate" an expression</title>
      <link>https://community.jmp.com/t5/Discussions/Can-t-quot-evaluate-quot-an-expression/m-p/40127#M23494</link>
      <description>Hi Justin,&lt;BR /&gt;&lt;BR /&gt;It doesn't work here. I'm on JMP 12.1 if that helps.&lt;BR /&gt;What it does is creating a tabulate, but it does not populate the content. I get columns A and B.&lt;BR /&gt;I have a single row and the count of A and B.</description>
      <pubDate>Thu, 08 Jun 2017 17:34:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Can-t-quot-evaluate-quot-an-expression/m-p/40127#M23494</guid>
      <dc:creator>matlag</dc:creator>
      <dc:date>2017-06-08T17:34:58Z</dc:date>
    </item>
    <item>
      <title>Re: Can't "evaluate" an expression</title>
      <link>https://community.jmp.com/t5/Discussions/Can-t-quot-evaluate-quot-an-expression/m-p/40132#M23495</link>
      <description>&lt;P&gt;What is your expected output? &amp;nbsp;I see a lot of things being generated and placed into lists, but I don't see anything being done with those things. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2017 19:30:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Can-t-quot-evaluate-quot-an-expression/m-p/40132#M23495</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-06-08T19:30:25Z</dc:date>
    </item>
    <item>
      <title>Re: Can't "evaluate" an expression</title>
      <link>https://community.jmp.com/t5/Discussions/Can-t-quot-evaluate-quot-an-expression/m-p/40138#M23497</link>
      <description>&lt;P&gt;Argh!&lt;/P&gt;&lt;P&gt;I understand the problem you have, I uploaded Test.jmp before saving a change.&lt;/P&gt;&lt;P&gt;Here is the right version.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Expected output (by copying in the log the result of the show())&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2017-06-08 16_02_54-Test - Tabulate - JMP Pro.png" style="width: 594px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/6391i2648CC17764399C5/image-size/large?v=v2&amp;amp;px=999" role="button" title="2017-06-08 16_02_54-Test - Tabulate - JMP Pro.png" alt="2017-06-08 16_02_54-Test - Tabulate - JMP Pro.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The reasons I'm going with a script like this are:&lt;/P&gt;&lt;P&gt;-The list of parameters in the real application is much longer&lt;/P&gt;&lt;P&gt;-The paremeters will change depending on my input data, but they're always documented.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2017 20:07:14 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Can-t-quot-evaluate-quot-an-expression/m-p/40138#M23497</guid>
      <dc:creator>matlag</dc:creator>
      <dc:date>2017-06-08T20:07:14Z</dc:date>
    </item>
    <item>
      <title>Re: Can't "evaluate" an expression</title>
      <link>https://community.jmp.com/t5/Discussions/Can-t-quot-evaluate-quot-an-expression/m-p/40150#M23504</link>
      <description>&lt;P&gt;It is certainly strange that the code does not appear to be fully executable in open code. &amp;nbsp;The only way that I was able to do it, was to convert your expresion tabExpr into a literal string, and to run it with Eval(Parse().&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;eval(parse("Tabulate(
	Set Format( Uniform Format( 10, 2 ) ),
	Add Table(
		Column Table( Grouping Columns( :Source ) ),
		Row Table(
			Analysis Column(
				Transform Column(\!"Parameter 1 Median\!", Ordinal, Formula( :P1_Q50 ) ),
				Transform Column(\!"Parameter 2 Median\!", Ordinal, Formula( :P2_Q50 ) )
			),
			Statistics( Median )
		)
	)
);"))&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Maybe one of the other community members have an idea&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2017 22:00:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Can-t-quot-evaluate-quot-an-expression/m-p/40150#M23504</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-06-08T22:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: Can't "evaluate" an expression</title>
      <link>https://community.jmp.com/t5/Discussions/Can-t-quot-evaluate-quot-an-expression/m-p/40162#M23506</link>
      <description>&lt;P&gt;This is indeed strange, and I haven't added much other than to put the code in one place. I suspect it's related to the use of virtual columns, but needs more investigation.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
ClearLog();

dt = New Table( "Test",
					Add Rows( 5 ),
					New Column( "P1_Q50",
						Numeric,
						"Continuous",
						Format( "Best", 12 ),
						Set Values( [32.6, 54.8, 48.9, 28, 51.4] )
					),
					New Column( "P2_Q50",
						Numeric,
						"Continuous",
						Format( "Best", 12 ),
						Set Values( [9, 7, 8, 6, 12] )
					),
					New Column( "Source",
						Character( 1 ),
						"Nominal",
						Set Values( {"A", "B", "B", "A", "B"} )
					)
				);

ParamsList = {
	{"P1", "Parameter 1"},
	{"P2", "Parameter 2"}
};

analysis = Expr(Analysis Column());

For (i=1, i&amp;lt;= Length(ParamsList), i++,
	Insert Into(
		analysis,
		Substitute(
			Expr(Transform Column("__Desc__", Formula(__Parameter__))),
			"__Desc__", ParamsList[i][2]||" Median",
			Expr(__Parameter__), Parse(":"||ParamsList[i][1]||"_Q50")
		)
	);
);

addRowExpr = Expr(Row Table());
Insert Into(addRowExpr, Eval Expr(analysis));
Insert Into(addRowExpr, Expr(Statistics(Median)));

addTabExpr = Expr(Add Table(Column Table(Grouping Columns(:Source))));
Insert Into(addTabExpr, Eval Expr(addRowExpr));

tabExpr = Expr(Tabulate(Set Format(Uniform Format(10,2))));
Insert Into(tabExpr, Eval Expr(addTabExpr));

show(tabExpr);
NewWindow("tabExpr", tabExpr);
NewWindow("Eval(Parse(Char(NameExpr(tabExpr))))", Eval(Parse(Char(NameExpr(tabExpr)))));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Jun 2017 08:38:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Can-t-quot-evaluate-quot-an-expression/m-p/40162#M23506</guid>
      <dc:creator>ian_jmp</dc:creator>
      <dc:date>2017-06-09T08:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: Can't "evaluate" an expression</title>
      <link>https://community.jmp.com/t5/Discussions/Can-t-quot-evaluate-quot-an-expression/m-p/40164#M23508</link>
      <description>&lt;P&gt;Using my "Morning Brain" I have come up with:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;eval(parse(char(evalexpr(tabexpr))))&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which will allow the expression that has been built to execute.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I agree with Ian, the code should work as developed, and I suggest you post the issue to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;support@jmp.com&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 09:35:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Can-t-quot-evaluate-quot-an-expression/m-p/40164#M23508</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-06-09T09:35:30Z</dc:date>
    </item>
    <item>
      <title>Re: Can't "evaluate" an expression</title>
      <link>https://community.jmp.com/t5/Discussions/Can-t-quot-evaluate-quot-an-expression/m-p/40166#M23510</link>
      <description>Hi Jim,&lt;BR /&gt;&lt;BR /&gt;Your solution works indeed! Thanks very much.&lt;BR /&gt;I'm contacting support.</description>
      <pubDate>Fri, 09 Jun 2017 12:00:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Can-t-quot-evaluate-quot-an-expression/m-p/40166#M23510</guid>
      <dc:creator>matlag</dc:creator>
      <dc:date>2017-06-09T12:00:07Z</dc:date>
    </item>
  </channel>
</rss>

