<?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 check existence of a macro variable . in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-check-existence-of-a-macro-variable/m-p/120100#M33070</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;Have you tried the &lt;SPAN style="font-family: 'courier new', courier;"&gt;%symexist&lt;/SPAN&gt; macro function?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 27 Jul 2012 14:55:30 GMT</pubDate>
    <dc:creator>Amir</dc:creator>
    <dc:date>2012-07-27T14:55:30Z</dc:date>
    <item>
      <title>How to check existence of a macro variable .</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-check-existence-of-a-macro-variable/m-p/120098#M33068</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt; Sometime I don't know whether there was a macro variable in the SAS environment and I want to delete it .It will show me a warning&amp;nbsp; message if the macro variable not exist when I trying to delete it.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;%let bbb=1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%SYMDEL&amp;nbsp; aaa bbb; /*try to delete aaa&amp;nbsp; and bbb,but aaa is not exist*/&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;"WARNING: Attempt to delete macro variable aaa&amp;nbsp; failed. Variable not found."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My question is ,To avoid the warning message.How to check whether a macro variable exist before delete it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jul 2012 14:40:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-check-existence-of-a-macro-variable/m-p/120098#M33068</guid>
      <dc:creator>Mike_Davis</dc:creator>
      <dc:date>2012-07-27T14:40:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to check existence of a macro variable .</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-check-existence-of-a-macro-variable/m-p/120099#M33069</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;%let bbb=1;&lt;/P&gt;&lt;P&gt;%put %symexist(bbb);&lt;/P&gt;&lt;P&gt;%put %symexist(aaa);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jul 2012 14:46:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-check-existence-of-a-macro-variable/m-p/120099#M33069</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-07-27T14:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to check existence of a macro variable .</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-check-existence-of-a-macro-variable/m-p/120100#M33070</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;Have you tried the &lt;SPAN style="font-family: 'courier new', courier;"&gt;%symexist&lt;/SPAN&gt; macro function?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jul 2012 14:55:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-check-existence-of-a-macro-variable/m-p/120100#M33070</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2012-07-27T14:55:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to check existence of a macro variable .</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-check-existence-of-a-macro-variable/m-p/120101#M33071</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could just add the /NOWARN option.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jul 2012 15:15:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-check-existence-of-a-macro-variable/m-p/120101#M33071</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-07-27T15:15:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to check existence of a macro variable .</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-check-existence-of-a-macro-variable/m-p/120102#M33072</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Presumably, you must be asking about open code.&amp;nbsp; Otherwise if you were talking about inside a macro, you could just use %SYMEXIST, as suggested by others:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%if %SYMEXIST(aaa) %then %SYMDEL(aaa);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since %IF is not permitted in open code, here's a way around that:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set sashelp.vmacro;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; where upcase(name)='AAA';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; call execute('%symdel(aaa);');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not sure if I have the syntax exactly right here, but the approach should work easily enough.&amp;nbsp; If you have a series of macro variables to delete, you would need to replace the WHERE statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if upcase(name) = 'AAA' then call execute('%symdel(aaa);');&lt;/P&gt;&lt;P&gt;else if upcase(name)='BBB' then call execute('%symdel(bbb);');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you need to apply this to a long series of macro variable names, you might as well write a macro and stick with %symexist / %symdel.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jul 2012 19:56:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-check-existence-of-a-macro-variable/m-p/120102#M33072</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-07-27T19:56:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to check existence of a macro variable .</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-check-existence-of-a-macro-variable/m-p/120103#M33073</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In case my previous message wasn't sufficiently clear, I think the following does exactly what you want:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let bbb=1;&lt;/P&gt;&lt;P&gt;%SYMDEL&amp;nbsp; aaa bbb /NOWARN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jul 2012 21:22:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-check-existence-of-a-macro-variable/m-p/120103#M33073</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-07-27T21:22:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to check existence of a macro variable .</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-check-existence-of-a-macro-variable/m-p/120104#M33074</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Art,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It doesn't get any better than that.&amp;nbsp; Good solution.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 28 Jul 2012 03:04:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-check-existence-of-a-macro-variable/m-p/120104#M33074</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-07-28T03:04:10Z</dc:date>
    </item>
  </channel>
</rss>

