<?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: macro numeric not equal operand in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macro-numeric-not-equal-operand/m-p/400087#M96970</link>
    <description>Get rid of the qoutes around _qc and _cc. Hardly necessary to quote anything in macro code.</description>
    <pubDate>Sun, 01 Oct 2017 06:00:20 GMT</pubDate>
    <dc:creator>error_prone</dc:creator>
    <dc:date>2017-10-01T06:00:20Z</dc:date>
    <item>
      <title>macro numeric not equal operand</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-numeric-not-equal-operand/m-p/400083#M96967</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a list of macro variables var1, var2 ... var&amp;amp;cnt that corresponds to variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, &amp;amp;var1 = price. I have a dataset with variables price_qc and price_cc, and if price_qc ne . then I want the new variable price = price_qc. Else, that is if price_qc is . , I want price = price_cc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to do the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro vars;
data want;
set have;
%do i = 1 %to &amp;amp;cnt;
%if &amp;amp;&amp;amp;var&amp;amp;i&amp;amp;'_qc' ne .   %then 
&amp;amp;&amp;amp;var&amp;amp;i = &amp;amp;&amp;amp;var&amp;amp;i&amp;amp;'_qc'  ;
%else 
&amp;amp;&amp;amp;var,i = &amp;amp;&amp;amp;var&amp;amp;i&amp;amp;'_cc';

%end;
run;
%mend;

%vars;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But I keep getting an error message:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"A character function was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:&lt;/P&gt;
&lt;P&gt;&amp;amp;&amp;amp;var&amp;amp;i&amp;amp;'_qc' ne . "&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried different possibilities of operands, but the realized that even the = operand gets the same message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Sun, 01 Oct 2017 05:13:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-numeric-not-equal-operand/m-p/400083#M96967</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2017-10-01T05:13:43Z</dc:date>
    </item>
    <item>
      <title>Re: macro numeric not equal operand</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-numeric-not-equal-operand/m-p/400087#M96970</link>
      <description>Get rid of the qoutes around _qc and _cc. Hardly necessary to quote anything in macro code.</description>
      <pubDate>Sun, 01 Oct 2017 06:00:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-numeric-not-equal-operand/m-p/400087#M96970</guid>
      <dc:creator>error_prone</dc:creator>
      <dc:date>2017-10-01T06:00:20Z</dc:date>
    </item>
    <item>
      <title>Re: macro numeric not equal operand</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-numeric-not-equal-operand/m-p/400095#M96975</link>
      <description>&lt;P&gt;A few changes:&amp;nbsp; removing quotes, removing the extra &amp;amp;, adding . to delimit macro variable names, changing %IF to IF:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%do i=1 %to &amp;amp;cnt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if &amp;amp;&amp;amp;var&amp;amp;i.._qc ne . then &amp;amp;&amp;amp;var&amp;amp;i = &amp;amp;&amp;amp;var&amp;amp;i.._qc;&lt;/P&gt;
&lt;P&gt;else &amp;amp;&amp;amp;var&amp;amp;i = &amp;amp;&amp;amp;var&amp;amp;i.._cc;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note, you may find it handy to examine the COALESCE function.&lt;/P&gt;</description>
      <pubDate>Sun, 01 Oct 2017 07:32:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-numeric-not-equal-operand/m-p/400095#M96975</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-10-01T07:32:07Z</dc:date>
    </item>
  </channel>
</rss>

