<?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: ERROR 388-185: Expecting an arithmetic operator.  ERROR 76-322: Syntax error, statement will be in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ERROR-388-185-Expecting-an-arithmetic-operator-ERROR-76-322/m-p/749540#M235557</link>
    <description>&lt;P&gt;From now on, please show us the entire log for this data step, so we can see the code and all messages; please do not show us just the errors&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You cannot mix and match macro variables and data step variables as you have done. &lt;FONT face="courier new,courier"&gt;&amp;amp;i&lt;/FONT&gt; is a macro variable, and it does not know about the data step variable called &lt;FONT face="courier new,courier"&gt;i&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why even use a macro variable here? This should work, although I cannot test it because I don't have your data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data bob2; 
       set bob;
    stat='N PCT N_ANY PCT_ANY';
       do i=1 to countw(stat);
        st=scan(stat,i);
        if st = 'N' then  _n=Y;
        if st = 'PCT' then  _pct=Y;
        if st = 'PERCENT' then  _pct=Y;
        if st = 'N_ANY' then  _nany=Y;
        if st = 'PCT_ANY' then  _pctany=Y;
        if _nany=Y or _pctany=Y then _anyev=Y;   
end; 
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 22 Jun 2021 14:27:11 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-06-22T14:27:11Z</dc:date>
    <item>
      <title>ERROR 388-185: Expecting an arithmetic operator.  ERROR 76-322: Syntax error, statement will be igno</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-388-185-Expecting-an-arithmetic-operator-ERROR-76-322/m-p/749533#M235552</link>
      <description>&lt;P&gt;Hello fellow SAS programmers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have this code that I cannot determine how to get beyond the error.&amp;nbsp; The error is "Expecting an arithmetic operator." But, I simply want to do a length of a macro variable value&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-sas"&gt;%let stat=%substr(N PCT N_ANY PCT_ANY,1);
data bob2; 
       set bob;
       do i=1 to length(&amp;amp;stat);
        %let st=upcase(scan("&amp;amp;stat",i));
        if &amp;amp;st = N then %let _n=Y;
        if &amp;amp;st = PCT then %let _pct=Y;
        if &amp;amp;st = PERCENT then %let _pct=Y;
        if &amp;amp;st = N_ANY then %let _nany=Y;
        if &amp;amp;st = PCT_ANY then %let _pctany=Y;
        if &amp;amp;_nany=Y or &amp;amp;_pctany=Y then %let _anyev=Y;   
end; 
run;

        &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;NOTE: Line generated by the macro variable "STAT".
1 N PCT N_ANY PCT_ANY
    ___
      388
       76
ERROR 388-185: Expecting an arithmetic operator. 
ERROR 76-322: Syntax error, statement will be ignored. &lt;/PRE&gt;
&lt;P&gt;If I use %length, I get notes such as the following:&lt;/P&gt;
&lt;PRE&gt;NOTE: Variable N is uninitialized.
NOTE: Variable PCT is uninitialized.
NOTE: Variable PERCENT is uninitialized.
NOTE: Variable N_ANY is uninitialized. 
NOTE: Variable PCT_ANY is uninitialized. 
NOTE: Variable Y is uninitialized. 

&lt;/PRE&gt;
&lt;P&gt;I do not even have a variable Y.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My question is: how do I avoid the error and the notes?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I keep it length(), I do not know how to avoid the error (expecting an arithmetic operator).&lt;/P&gt;
&lt;P&gt;If I keep the %length, I do not know how to avoid the notes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you in advance for your support and for reading my question.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jun 2021 13:47:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-388-185-Expecting-an-arithmetic-operator-ERROR-76-322/m-p/749533#M235552</guid>
      <dc:creator>Sarah-R</dc:creator>
      <dc:date>2021-06-22T13:47:07Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 388-185: Expecting an arithmetic operator.  ERROR 76-322: Syntax error, statement will be</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-388-185-Expecting-an-arithmetic-operator-ERROR-76-322/m-p/749540#M235557</link>
      <description>&lt;P&gt;From now on, please show us the entire log for this data step, so we can see the code and all messages; please do not show us just the errors&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You cannot mix and match macro variables and data step variables as you have done. &lt;FONT face="courier new,courier"&gt;&amp;amp;i&lt;/FONT&gt; is a macro variable, and it does not know about the data step variable called &lt;FONT face="courier new,courier"&gt;i&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why even use a macro variable here? This should work, although I cannot test it because I don't have your data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data bob2; 
       set bob;
    stat='N PCT N_ANY PCT_ANY';
       do i=1 to countw(stat);
        st=scan(stat,i);
        if st = 'N' then  _n=Y;
        if st = 'PCT' then  _pct=Y;
        if st = 'PERCENT' then  _pct=Y;
        if st = 'N_ANY' then  _nany=Y;
        if st = 'PCT_ANY' then  _pctany=Y;
        if _nany=Y or _pctany=Y then _anyev=Y;   
end; 
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 Jun 2021 14:27:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-388-185-Expecting-an-arithmetic-operator-ERROR-76-322/m-p/749540#M235557</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-06-22T14:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 388-185: Expecting an arithmetic operator.  ERROR 76-322: Syntax error, statement will be</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-388-185-Expecting-an-arithmetic-operator-ERROR-76-322/m-p/749563#M235571</link>
      <description>&lt;LI-CODE lang="sas"&gt;
data bob2; 
       set bob;
    stat='N PCT N_ANY PCT_ANY';
       do i=1 to countw(stat);
        st=scan(stat,i);
        if st = "N" then  _n="Y";
        if st = "PCT" then  _pct="Y";
        if st = "PERCENT" then  _pct="Y";
        if st = "N_ANY" then  _nany="Y";
        if st = "PCT_ANY" then  _pctany="Y";
        if _nany="Y" or _pctany="Y" then _anyev="Y";   
end; 
run;&lt;/LI-CODE&gt;
&lt;P&gt;In the original code the values on the RIGHT of the = N PCT PERCENT N_ANY PCT_ANY and Y&amp;nbsp; since they were not quoted were treated as variable &lt;STRONG&gt;names&lt;/STRONG&gt; that had no values assigned. Hence the "uninitialized" notes. &lt;/P&gt;</description>
      <pubDate>Tue, 22 Jun 2021 14:31:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-388-185-Expecting-an-arithmetic-operator-ERROR-76-322/m-p/749563#M235571</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-06-22T14:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 388-185: Expecting an arithmetic operator.  ERROR 76-322: Syntax error, statement will be</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-388-185-Expecting-an-arithmetic-operator-ERROR-76-322/m-p/749573#M235578</link>
      <description>&lt;P&gt;So the error is from this function call:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;length(&amp;amp;stat)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So based on how you defined the macro variable STAT this is the code that SAS sees after the macro processor has finished replacing the macro code with the generated text:&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-sas"&gt;length(N PCT N_ANY PCT_ANY)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to evaluate the length of that string you could either use the macro function %LENGTH() or give the LENGTH() function a string to evaluate.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%length(&amp;amp;stat)
length("&amp;amp;stat")&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But as you note this does not fix the logic problem you have with your code.&amp;nbsp; You are increasing the value if I based on the number of characters in the string.&amp;nbsp; But you are actually testing based on the number of "words" in the string.&amp;nbsp; To count that use the COUNTW() function, not the LENGTH() function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How ever the whole program is extremely confused.&amp;nbsp; For example this statement makes no sense at all.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if &amp;amp;st = N then %let _n='Y';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Once the macro processor has finished the condition will be valid (but useless) SAS code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if upcase(scan("N PCT N_ANY PCT_ANY",i)) = N then;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So the macro variables ST and STAT will resolve to a valid SAS function call on the left of the equality operator.&amp;nbsp; The result of that upcase() function will be compared the variable N.&amp;nbsp; Does your dataset include a variable named N?&amp;nbsp; But no matter whether the equality test is TRUE or FALSE there is no SAS statement to be executed after the THEN statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please explain what you are trying to do.&amp;nbsp; Provide example input data and the expected resulting data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jun 2021 14:56:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-388-185-Expecting-an-arithmetic-operator-ERROR-76-322/m-p/749573#M235578</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-06-22T14:56:09Z</dc:date>
    </item>
  </channel>
</rss>

