<?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 variable not behaving as expected in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-not-behaving-as-expected/m-p/178793#M34187</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks so much..&lt;/P&gt;&lt;P&gt;Bruce&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 30 May 2014 18:11:57 GMT</pubDate>
    <dc:creator>BigD</dc:creator>
    <dc:date>2014-05-30T18:11:57Z</dc:date>
    <item>
      <title>Macro variable not behaving as expected</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-not-behaving-as-expected/m-p/178790#M34184</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a litte macro that reports the agencies that did not complete a submission.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff; font-size: 10pt; font-family: Courier New;"&gt;/*get the names of the agencies that did not report*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;STRONG style=": ; font-size: 10pt; font-family: Courier New;"&gt;sql&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;noprint&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; SELECT agency &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;into&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;:missing_agency separated &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;' and '&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; color: #3366ff; font-size: 10pt; font-family: Courier New;"&gt;from agency_list;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;quit;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;SYMBOLGEN:&amp;nbsp; Macro variable MISSING_agency resolves to agency1 and agency2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;/*MACRO TO WRITE THE NAME OF THE NON REPORTERS, IF ANY*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt; %macro DidnotReport_AGENCY(missing_agency);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt; %if &amp;amp;missing_agency = %str() %then %do;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt; /*%put "Macro Variable is empty";*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;&amp;nbsp; %end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;&amp;nbsp; %else %do;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt; ods region&amp;nbsp; x=1.0in y=6.5in;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;Ods pdf text="^S={font=('Arial' ,10pt, bold ) just=center } Note: %trim(&amp;amp;Missing_agency) did not report this week";&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt; %end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt; %mend;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;/*RUN THE MACRO*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;%didnotreport_AGENCY(&amp;amp;missing_agency);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;&amp;nbsp; operand is required. The condition was: &amp;amp;missing_agency =&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;ERROR: The macro DIDNOTREPORT_agency will stop executing.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 10pt;"&gt;So I figured it had something to do with the fact that there are two non reporters (macro works well with only one non-reporting agency)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;so I reasigned the missing agency to "peter"&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;&amp;nbsp; %let missing_agency = peter;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-size: 10pt;"&gt;AND THE LOG SAID:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;SYMBOLGEN:&amp;nbsp; Macro variable MISSING_agency resolves to agency1 and agency2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;NOTE: A missing equal sign has been inserted after the variable name agency1.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;That's interesting!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Why does this happen? And how can I get the name of two agencies to list in the report?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 May 2014 17:18:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-not-behaving-as-expected/m-p/178790#M34184</guid>
      <dc:creator>BigD</dc:creator>
      <dc:date>2014-05-30T17:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable not behaving as expected</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-not-behaving-as-expected/m-p/178791#M34185</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;code it this way:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %if "&amp;amp;missing_agency " = " " %then %do;&lt;BR /&gt;By that your value testing will be string based comparison.&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In you original code the string is put into the macro language. You error message is telling you you have a macro language error.&lt;BR /&gt;Think of using SAS macro-s you can modify all kind of strings before it is going (reviewed ) into those nested language interpreters. &lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 May 2014 17:33:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-not-behaving-as-expected/m-p/178791#M34185</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2014-05-30T17:33:29Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable not behaving as expected</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-not-behaving-as-expected/m-p/178792#M34186</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The word AND is tripping up the implied %eval() in the %IF statement.&amp;nbsp; You can add macro quoting:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%if %superq(missing_agency)=%str() ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or for a utility macro %IsBlank that does this check for you, see:&lt;/P&gt;&lt;P&gt;&lt;A href="http://changchung.com/download/022-2009.pdf"&gt;http://changchung.com/download/022-2009.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 May 2014 17:38:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-not-behaving-as-expected/m-p/178792#M34186</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2014-05-30T17:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable not behaving as expected</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-not-behaving-as-expected/m-p/178793#M34187</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks so much..&lt;/P&gt;&lt;P&gt;Bruce&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 May 2014 18:11:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-not-behaving-as-expected/m-p/178793#M34187</guid>
      <dc:creator>BigD</dc:creator>
      <dc:date>2014-05-30T18:11:57Z</dc:date>
    </item>
  </channel>
</rss>

