<?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: How to remove inverted commas in a varible name in a formula in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-remove-inverted-commas-in-a-varible-name-in-a-formula/m-p/107574#M39183</link>
    <description>Hi gianpaolo_polsi,&lt;BR /&gt;Thanks for the script, I think I can use for other purposes, however, it does not solve my problem:If( Is Missing( {"Status (LOA)"} ),&lt;BR /&gt;.,&lt;BR /&gt;{"LOA (QC1007AI),%"}&lt;BR /&gt;)&lt;BR /&gt;I do not understand why I get these " " marks in my formula when I script it.</description>
    <pubDate>Wed, 23 Jan 2019 08:21:35 GMT</pubDate>
    <dc:creator>Sop</dc:creator>
    <dc:date>2019-01-23T08:21:35Z</dc:date>
    <item>
      <title>How to remove inverted commas in a varible name in a formula</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-remove-inverted-commas-in-a-varible-name-in-a-formula/m-p/107524#M39154</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I would like to choose two columns and do the formula. However, the variables in the formula have " " around the name and therefore is does not work. Aný suggestions?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();
win = New Window( "Clean False Zeroes",
&amp;lt;&amp;lt;Modal,
Text Box( "Available Columns" ),
H List Box(
// list box to present cols
allcols = Col List Box( dt, all ), // or specify numeric instead of all
Lineup Box(
2,
bbx = Button Box( "X, Factor", xcols &amp;lt;&amp;lt; append( allcols &amp;lt;&amp;lt; get selected ) ),
// list box to receive cols
xcols = Col List Box( "Numeric", &amp;lt;&amp;lt;Modeling Type( {"Continuous"} ), min items( 1 ) ),
bby = Button Box( "Status, Response", ycols &amp;lt;&amp;lt; append( allcols &amp;lt;&amp;lt; get selected ) ),
// list box to receive cols
ycols = Col List Box( "Character", &amp;lt;&amp;lt;Modeling Type( {"Nominal"} ), min items( 1 ) )

),
V List Box(
bbOK = Button Box( "OK",
xvar = (xcols &amp;lt;&amp;lt; Get Items);
yvar = (ycols &amp;lt;&amp;lt; Get Items);
Show( xvar );

),
bbCancel = Button Box( "Cancel" )

)
)
);
// stop the script if user chooses Cancel
If( win["Button"] == -1,
Throw( "User Cancelled" )

);
　
FalseZeroes = Expr(
dt &amp;lt;&amp;lt; New Column( "Temp", Numeric, "Continuous", Format( "Best", 12 ), formula( If( Is Missing( :Expr( yvar ) ), ., :Expr( xvar ) ) ) )

);
Eval( Eval Expr( FalseZeroes ) );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 20:01:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-remove-inverted-commas-in-a-varible-name-in-a-formula/m-p/107524#M39154</guid>
      <dc:creator>Sop</dc:creator>
      <dc:date>2019-01-23T20:01:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove inverted commas in a varible name in a formula</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-remove-inverted-commas-in-a-varible-name-in-a-formula/m-p/107525#M39155</link>
      <description>&lt;P&gt;Hello Sop&lt;/P&gt;
&lt;P&gt;try this code to the data table before to&amp;nbsp;apply formulas&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// code to replace any special JMP character with single char " : "
For(i = 1, i &amp;lt;= N Col(dt), i++,
Column(dt, i) &amp;lt;&amp;lt; set name(Regex(Column(dt, i) &amp;lt;&amp;lt; get name, "\W", ":", GLOBALREPLACE))

);
&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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 20:01:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-remove-inverted-commas-in-a-varible-name-in-a-formula/m-p/107525#M39155</guid>
      <dc:creator>gianpaolo</dc:creator>
      <dc:date>2019-01-23T20:01:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove inverted commas in a varible name in a formula</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-remove-inverted-commas-in-a-varible-name-in-a-formula/m-p/107527#M39156</link>
      <description>&lt;P&gt;underscore might be a better choice than colon because the colon is an operator.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2019 15:59:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-remove-inverted-commas-in-a-varible-name-in-a-formula/m-p/107527#M39156</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2019-01-22T15:59:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove inverted commas in a varible name in a formula</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-remove-inverted-commas-in-a-varible-name-in-a-formula/m-p/107574#M39183</link>
      <description>Hi gianpaolo_polsi,&lt;BR /&gt;Thanks for the script, I think I can use for other purposes, however, it does not solve my problem:If( Is Missing( {"Status (LOA)"} ),&lt;BR /&gt;.,&lt;BR /&gt;{"LOA (QC1007AI),%"}&lt;BR /&gt;)&lt;BR /&gt;I do not understand why I get these " " marks in my formula when I script it.</description>
      <pubDate>Wed, 23 Jan 2019 08:21:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-remove-inverted-commas-in-a-varible-name-in-a-formula/m-p/107574#M39183</guid>
      <dc:creator>Sop</dc:creator>
      <dc:date>2019-01-23T08:21:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove inverted commas in a varible name in a formula</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-remove-inverted-commas-in-a-varible-name-in-a-formula/m-p/107671#M39188</link>
      <description>&lt;P&gt;We'd need to see more of the JSL that is creating the script to give a better answer, but&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;{"LOA (QC1007AI),%"}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is a list of one quoted string. (The curly brackets make a list.) You can get the item out of the list and be a little closer&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;colNames = {"LOA (QC1007AI),%"};
theColumnName = colnames[1];
print(theColumnName); &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You'll need to make a column from the column name for most usage.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;col = column( dt, theColumnName );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the column function will look up the name in the data table and return the column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you may have used a function that returns the names of columns rather than a function that returns columns. There is a good post&amp;nbsp;&lt;A href="http://www.pega-analytics.co.uk/blog/column-references/" target="_blank" rel="noopener"&gt;http://www.pega-analytics.co.uk/blog/column-references/&lt;/A&gt;&amp;nbsp;discussing some of these issues.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 11:40:10 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-remove-inverted-commas-in-a-varible-name-in-a-formula/m-p/107671#M39188</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2019-01-23T11:40:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove inverted commas in a varible name in a formula</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-remove-inverted-commas-in-a-varible-name-in-a-formula/m-p/107678#M39195</link>
      <description>&lt;P&gt;also based on Craige&amp;nbsp;input(thanks!) i&amp;nbsp; arranged script using Column dialog editor&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();
 
cd=column Dialog(
Title(" Clean False Zeroes "),
xcols= ColList(" Numeric ", MinCol( 1 ), DataType("Numeric"), modeling type("Continuous") ),
ycols= ColList(" Character ", MinCol( 1 ), DataType("Character"), modeling type("Nominal") ),
);
　
 
xvar =cd["xcols"];
yvar =cd["ycols"];
　
xvar=xvar[1];
yvar=yvar[1];
dt &amp;lt;&amp;lt; new column("check",, formula(If(Is Missing(yvar),.,xvar) ) );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 20:04:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-remove-inverted-commas-in-a-varible-name-in-a-formula/m-p/107678#M39195</guid>
      <dc:creator>gianpaolo</dc:creator>
      <dc:date>2019-01-23T20:04:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove inverted commas in a varible name in a formula</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-remove-inverted-commas-in-a-varible-name-in-a-formula/m-p/107756#M39229</link>
      <description>&lt;P&gt;I think you want to do something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; new column("check",
formula(eval(evalexpr(If(Is Missing(expr(nameexpr(yvar))),.,expr(nameexpr(xvar))) )))
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="The selected names are in the script" style="width: 274px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/15214i0C31B95988986AB4/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture1.PNG" alt="The selected names are in the script" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;The selected names are in the script&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Without the extra work, you get something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="The variable names are in the script" style="width: 238px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/15215i3B70636BC6E4625E/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture2.PNG" alt="The variable names are in the script" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;The variable names are in the script&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Which only works as long as yvar holds :name and xvar holds :height. That will not be the case if you save the table, close and restart JMP, then open the table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What does it do?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;eval&lt;/EM&gt;() is a signal to &lt;EM&gt;formula&lt;/EM&gt; to evaluate its argument. Normally you would not want that because normally the expression you give to &lt;EM&gt;formula&lt;/EM&gt;() should not be evaluated until the column needs to run it. So the first code that runs is &lt;EM&gt;evalexpr&lt;/EM&gt;() which will return a rewritten expression for the formula column. &lt;EM&gt;Evalexpr&lt;/EM&gt; looks in its argument for &lt;EM&gt;expr&lt;/EM&gt;() functions it can evaluate and replace with the result; there are two of them. So what gets evaluated is the &lt;EM&gt;NameExpr&lt;/EM&gt; function, which returns the name of its argument...xval's argument and name is :height.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 19:59:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-remove-inverted-commas-in-a-varible-name-in-a-formula/m-p/107756#M39229</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2019-01-23T19:59:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove inverted commas in a varible name in a formula</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-remove-inverted-commas-in-a-varible-name-in-a-formula/m-p/107918#M39251</link>
      <description>&lt;P&gt;Thank you both for your suggestions, however, none of them works for me. For clarification, I have made a test file with the data in column A, Status in col B. Then I have made a third column with the formula included. You can ses that it works. If I run the script to do the same (I do not know which columns I want to clean for zeroes) you see in column 4 that it does not work well. Hope it all makes sense.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();
win = New Window( "Clean False Zeroes",
	&amp;lt;&amp;lt;Modal,
	Text Box( "Available Columns" ),
	H List Box(
		// list box to present cols
		allcols = Col List Box( dt, all ), // or specify numeric instead of all
		Lineup Box(
			2,
			bbx = Button Box( "X, Factor", xcols &amp;lt;&amp;lt; append( allcols &amp;lt;&amp;lt; get selected ) ), 
			// list box to receive cols
			xcols = Col List Box( "Numeric", &amp;lt;&amp;lt;Modeling Type( {"Continuous"} ), min items( 1 ) ),
			bby = Button Box( "Status, Response", ycols &amp;lt;&amp;lt; append( allcols &amp;lt;&amp;lt; get selected ) ), 
			// list box to receive cols
			ycols = Col List Box( "Character", &amp;lt;&amp;lt;Modeling Type( {"Nominal"} ), min items( 1 ) )
		),
		V List Box(
			bbOK = Button Box( "OK",
				xvar = (xcols &amp;lt;&amp;lt; Get Items);
				yvar = (ycols &amp;lt;&amp;lt; Get Items);
				Show( xvar );
			),
			bbCancel = Button Box( "Cancel" )
		)
	)
);
// stop the script if user chooses Cancel
If( win["Button"] == -1,
	Throw( "User Cancelled" )
);



FalseZeroes = Expr(
	dt &amp;lt;&amp;lt; New Column( "Temp", Numeric, "Continuous", Format( "Best", 12 ), formula( If( Is Missing( :Expr( yvar ) ), ., :Expr( xvar ) ) ) )
);
Eval( Eval Expr( FalseZeroes ) );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Jan 2019 12:03:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-remove-inverted-commas-in-a-varible-name-in-a-formula/m-p/107918#M39251</guid>
      <dc:creator>Sop</dc:creator>
      <dc:date>2019-01-24T12:03:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove inverted commas in a varible name in a formula</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-remove-inverted-commas-in-a-varible-name-in-a-formula/m-p/107919#M39252</link>
      <description>Hey! It works if I use the nameexpr. Thank you both for you help. I am really happy.</description>
      <pubDate>Thu, 24 Jan 2019 12:09:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-remove-inverted-commas-in-a-varible-name-in-a-formula/m-p/107919#M39252</guid>
      <dc:creator>Sop</dc:creator>
      <dc:date>2019-01-24T12:09:40Z</dc:date>
    </item>
  </channel>
</rss>

