<?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: SYSEVAF function to evaulate a expression stored in character (SKIP syntax) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SYSEVAF-function-to-evaulate-a-expression-stored-in-character/m-p/241073#M44611</link>
    <description>&lt;P&gt;OK, one last try at what I think you need to solve here. &amp;nbsp;It is only being applied to one formula at a time, since it appears that you need to decide whether or not to proceed with processing based on whether the formula is valid.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;input exp $20.;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;call symputx('formula', exp);&lt;BR /&gt;&lt;SPAN&gt;cards;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;701*10 ** 6&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;%let proceed=Y;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;check = &amp;amp;formula;&lt;/P&gt;
&lt;P&gt;if check=. then call symputx('proceed', 'N');&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;%if &amp;amp;syserr &amp;gt; 0 %then %let proceed=N;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This gives you a macro variable &amp;amp;PROCEED that will be Y if you are safe, but N if either bad outcome is present: &amp;nbsp;the input formula contains invalid syntax, or the input formula generates a missing value (possibly because of referring to an unknown variable name).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are we getting close?&lt;/P&gt;</description>
    <pubDate>Mon, 28 Dec 2015 20:05:39 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2015-12-28T20:05:39Z</dc:date>
    <item>
      <title>SYSEVAF function to evaulate a expression stored in character (SKIP syntax)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SYSEVAF-function-to-evaulate-a-expression-stored-in-character/m-p/240961#M44563</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset in which one of the variable has arithmetic expression. These expression are entered by user and it contains syntax errors. See dataset below where observation 2,3 and 4 are incorrect expression. If I use sysevalf or evalf function to evaluate them it throws the syntax error as below.&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt;input exp $20.;&lt;BR /&gt;cards;&lt;BR /&gt;701*10 ** 6&lt;BR /&gt;4..60*10 ** 6&lt;BR /&gt;6t.22 * 10**-4&lt;BR /&gt;2*10**-3s&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IS there any function to parse these expression befor applying the sysevalf function. Please help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Anand&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2015 01:12:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SYSEVAF-function-to-evaulate-a-expression-stored-in-character/m-p/240961#M44563</guid>
      <dc:creator>anandbillava</dc:creator>
      <dc:date>2015-12-28T01:12:36Z</dc:date>
    </item>
    <item>
      <title>Re: SYSEVAF function to evaulate a expression stored in character (SKIP syntax)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SYSEVAF-function-to-evaulate-a-expression-stored-in-character/m-p/240973#M44566</link>
      <description>Depends. It looks like the errors are in the variables with characters? If so you could use anyalpha to identify records that may be an issue. However, with a user entered field you're bound to find errors in unknown and unpredictable ways. It may be better to try and catch the error rather than accommodate for it. Not sure how that's accomplished in SAS.</description>
      <pubDate>Mon, 28 Dec 2015 02:56:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SYSEVAF-function-to-evaulate-a-expression-stored-in-character/m-p/240973#M44566</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-12-28T02:56:09Z</dc:date>
    </item>
    <item>
      <title>Re: SYSEVAF function to evaulate a expression stored in character (SKIP syntax)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SYSEVAF-function-to-evaulate-a-expression-stored-in-character/m-p/240976#M44567</link>
      <description>&lt;P&gt;There are a lot of pattern you need to match. This one could relieve your task.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input exp $20.;
if prxmatch('/^((-?\d+(\.\d+)?)(\+|-|\*{1,2}|\/)?)+$/',compress(exp)) then
x=resolve(cats('%sysevalf(',exp,')')); 
cards;
701*10 ** 6
4..60*10 ** 6
6t.22 * 10**-4
2*10**-3s
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Dec 2015 03:35:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SYSEVAF-function-to-evaulate-a-expression-stored-in-character/m-p/240976#M44567</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-12-28T03:35:49Z</dc:date>
    </item>
    <item>
      <title>Re: SYSEVAF function to evaulate a expression stored in character (SKIP syntax)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SYSEVAF-function-to-evaulate-a-expression-stored-in-character/m-p/241011#M44581</link>
      <description>&lt;P&gt;Depending on what you consider a solution to be, consider this approach:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;call execute('data _null_; set have; file print;');&lt;/P&gt;
&lt;P&gt;do until (done);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;set have end=done;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;call execute ('testvar = ' || exp || '; put exp&amp;nbsp;@ ;');&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;call execute ('if testvar=. then put &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/54795"&gt;@25&lt;/a&gt; "Result: &amp;nbsp;Not valid"; else put&amp;nbsp;@25 "Result: &amp;nbsp;Valid";')&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;call execute('run;');&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The intent is to generate a report showing whether each expression is valid or not. &amp;nbsp;I'm just not sure if that is an acceptable outcome or not. &amp;nbsp;Also note, the code is untested so it may need slight tweaking.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2015 14:50:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SYSEVAF-function-to-evaulate-a-expression-stored-in-character/m-p/241011#M44581</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-12-28T14:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: SYSEVAF function to evaulate a expression stored in character (SKIP syntax)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SYSEVAF-function-to-evaulate-a-expression-stored-in-character/m-p/241013#M44582</link>
      <description>&lt;P&gt;Thank you Both.&lt;/P&gt;
&lt;P&gt;Regular expression solution is working partially. But its not working for all the formulas. I am not well versed in regular expression so trying to fine tune it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;for e.g. if the rule is like this&amp;nbsp;(45.25/46.00*23.06). This contains the open and close braces. Its not evaluating such rules.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2015 15:09:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SYSEVAF-function-to-evaulate-a-expression-stored-in-character/m-p/241013#M44582</guid>
      <dc:creator>anandbillava</dc:creator>
      <dc:date>2015-12-28T15:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: SYSEVAF function to evaulate a expression stored in character (SKIP syntax)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SYSEVAF-function-to-evaulate-a-expression-stored-in-character/m-p/241014#M44583</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This solution is failing as we are really not checking the rule prior to the execution. Directly executing the rule is throwing the syntax error.&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>Mon, 28 Dec 2015 15:10:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SYSEVAF-function-to-evaulate-a-expression-stored-in-character/m-p/241014#M44583</guid>
      <dc:creator>anandbillava</dc:creator>
      <dc:date>2015-12-28T15:10:23Z</dc:date>
    </item>
    <item>
      <title>Re: SYSEVAF function to evaulate a expression stored in character (SKIP syntax)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SYSEVAF-function-to-evaulate-a-expression-stored-in-character/m-p/241046#M44596</link>
      <description>You can't fix bad design/process with coding on the back end. You may want to find a way to clean the formula's before you bring them into SAS or some other way. As phrased this seems a bit like a programming exercise.</description>
      <pubDate>Mon, 28 Dec 2015 18:15:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SYSEVAF-function-to-evaulate-a-expression-stored-in-character/m-p/241046#M44596</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-12-28T18:15:57Z</dc:date>
    </item>
    <item>
      <title>Re: SYSEVAF function to evaulate a expression stored in character (SKIP syntax)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SYSEVAF-function-to-evaulate-a-expression-stored-in-character/m-p/241073#M44611</link>
      <description>&lt;P&gt;OK, one last try at what I think you need to solve here. &amp;nbsp;It is only being applied to one formula at a time, since it appears that you need to decide whether or not to proceed with processing based on whether the formula is valid.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;input exp $20.;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;call symputx('formula', exp);&lt;BR /&gt;&lt;SPAN&gt;cards;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;701*10 ** 6&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;%let proceed=Y;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;check = &amp;amp;formula;&lt;/P&gt;
&lt;P&gt;if check=. then call symputx('proceed', 'N');&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;%if &amp;amp;syserr &amp;gt; 0 %then %let proceed=N;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This gives you a macro variable &amp;amp;PROCEED that will be Y if you are safe, but N if either bad outcome is present: &amp;nbsp;the input formula contains invalid syntax, or the input formula generates a missing value (possibly because of referring to an unknown variable name).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are we getting close?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2015 20:05:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SYSEVAF-function-to-evaulate-a-expression-stored-in-character/m-p/241073#M44611</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-12-28T20:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: SYSEVAF function to evaulate a expression stored in character (SKIP syntax)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SYSEVAF-function-to-evaulate-a-expression-stored-in-character/m-p/241086#M44620</link>
      <description>My Perl Regular Expression would cover  (45.25/46.00*23.06) .&lt;BR /&gt;As I said before, there are too many rules you need consider. You can't expect what kind of error the user would enter . The only way is to enhance and perfect the PRX better and better .</description>
      <pubDate>Tue, 29 Dec 2015 00:54:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SYSEVAF-function-to-evaulate-a-expression-stored-in-character/m-p/241086#M44620</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-12-29T00:54:41Z</dc:date>
    </item>
  </channel>
</rss>

