<?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 Check to see if macro exists in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-macro-exists/m-p/121141#M24824</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to check to see if a macro variable exists. I use a %WINDOW to allow users to enter values. The user does not have to enter a value for all options, since in my actual program there are &amp;gt;40 options. I'm trying to find a way to see which ones the user enters a value for.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When testing this, I entered values for the first 2, and left the third one blank (IBCP_SCP). I researched the internet and stumbled across %SYMEXIST and %SYSMACEXIST, but those didn't seem to help (I included the code I tried below).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I appreciate any help you can provide. Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%WINDOW VOLADJST&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @35 "Volume Adjustment Inputs (eg. For 5%, enter 5, NOT .05)" COLOR = BLUE&lt;/P&gt;&lt;P&gt;#6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @10 "Inbound Competitive" COLOR = RED //&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @15 "EMS" COLOR = BLACK +2 IBCP_EMS 4 COLOR = GREEN REQUIRED = NO ATTR = UNDERLINE /&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @15 "Air" COLOR = BLACK +2 IBCP_ACP 4 COLOR = GREEN REQUIRED = NO ATTR = UNDERLINE /&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @15 "Suface" COLOR = BLACK +2 IBCP_SCP 4 COLOR = GREEN REQUIRED = NO ATTR = UNDERLINE&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%DISPLAY VOLADJST;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*I got all true's when I ran the step below*/&lt;/P&gt;&lt;P&gt;%macro test;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %if %symexist(IBCP_EMS) %then %put %nrstr(%symexist(IBCP_EMS)) = TRUE;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %else %put %nrstr(%symexist(IBCP_EMS)) = FALSE;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %if %symexist(IBCP_ACP) %then %put %nrstr(%symexist(IBCP_ACP)) = TRUE;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %else %put %nrstr(%symexist(IBCP_ACP)) = FALSE;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %if %symexist(IBCP_SCP) %then %put %nrstr(%symexist(IBCP_SCP)) = TRUE;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %else %put %nrstr(%symexist(IBCP_SCP)) = FALSE;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%test;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*I got all 0's when I ran the step below*/&lt;/P&gt;&lt;P&gt;DATA X;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A = %sysmacexist(IBCP_EMS);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B = %sysmacexist(IBCP_ACP);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; C = %sysmacexist(IBCP_SCP);&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 08 Nov 2012 15:13:36 GMT</pubDate>
    <dc:creator>stat11</dc:creator>
    <dc:date>2012-11-08T15:13:36Z</dc:date>
    <item>
      <title>Check to see if macro exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-macro-exists/m-p/121141#M24824</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to check to see if a macro variable exists. I use a %WINDOW to allow users to enter values. The user does not have to enter a value for all options, since in my actual program there are &amp;gt;40 options. I'm trying to find a way to see which ones the user enters a value for.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When testing this, I entered values for the first 2, and left the third one blank (IBCP_SCP). I researched the internet and stumbled across %SYMEXIST and %SYSMACEXIST, but those didn't seem to help (I included the code I tried below).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I appreciate any help you can provide. Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%WINDOW VOLADJST&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @35 "Volume Adjustment Inputs (eg. For 5%, enter 5, NOT .05)" COLOR = BLUE&lt;/P&gt;&lt;P&gt;#6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @10 "Inbound Competitive" COLOR = RED //&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @15 "EMS" COLOR = BLACK +2 IBCP_EMS 4 COLOR = GREEN REQUIRED = NO ATTR = UNDERLINE /&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @15 "Air" COLOR = BLACK +2 IBCP_ACP 4 COLOR = GREEN REQUIRED = NO ATTR = UNDERLINE /&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @15 "Suface" COLOR = BLACK +2 IBCP_SCP 4 COLOR = GREEN REQUIRED = NO ATTR = UNDERLINE&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%DISPLAY VOLADJST;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*I got all true's when I ran the step below*/&lt;/P&gt;&lt;P&gt;%macro test;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %if %symexist(IBCP_EMS) %then %put %nrstr(%symexist(IBCP_EMS)) = TRUE;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %else %put %nrstr(%symexist(IBCP_EMS)) = FALSE;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %if %symexist(IBCP_ACP) %then %put %nrstr(%symexist(IBCP_ACP)) = TRUE;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %else %put %nrstr(%symexist(IBCP_ACP)) = FALSE;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %if %symexist(IBCP_SCP) %then %put %nrstr(%symexist(IBCP_SCP)) = TRUE;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %else %put %nrstr(%symexist(IBCP_SCP)) = FALSE;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%test;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*I got all 0's when I ran the step below*/&lt;/P&gt;&lt;P&gt;DATA X;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A = %sysmacexist(IBCP_EMS);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B = %sysmacexist(IBCP_ACP);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; C = %sysmacexist(IBCP_SCP);&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Nov 2012 15:13:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-macro-exists/m-p/121141#M24824</guid>
      <dc:creator>stat11</dc:creator>
      <dc:date>2012-11-08T15:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: Check to see if macro exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-macro-exists/m-p/121142#M24825</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You seem to be confusing macros with macro variables.&amp;nbsp; In your example code TEST is macro and IBCP_EMS and the others are macro variables.&amp;nbsp; So of course the test for whether the macro IBCP_EMS exists will return 0 (false) unless you have defined it previously with a %MACRO statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Nov 2012 15:20:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-macro-exists/m-p/121142#M24825</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-11-08T15:20:05Z</dc:date>
    </item>
    <item>
      <title>Re: Check to see if macro exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-macro-exists/m-p/121143#M24826</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;As Tom pointed out, %symexist() tests whether or not a macro variable (symbol) exists.&amp;nbsp; %sysmacexist() tests whether a macro exists.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your case, looks like you are using the %window statement to gather input values from users.&amp;nbsp; As I understand it, the %window statement you have will always create three macro variables.&amp;nbsp; But, the user may have left some of the values blank.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Even if a user does not input a value for &amp;amp;IBCP_EMS, the macro variables still exists, and the value is blank.&amp;nbsp; So %symexist() can't help you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What you need is a way to test if a macro symbol is blank or not.&amp;nbsp; Luckily for you, Chang Chung and John King wrote a great paper on methods for doing this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings09/022-2009.pdf"&gt;http://support.sas.com/resources/papers/proceedings09/022-2009.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And they concluded with a suggestion for a simple macro, %isBlank, which should work for you, e.g.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;%macro isBlank(param) ;
&amp;nbsp; %sysevalf(%superq(param)=,boolean)
%mend isBlank ;

%put %isBlank(&amp;amp;IBCP_EMS) ;
%put %isBlank(&amp;amp;IBCP_ACP) ;
%put %isBlank(&amp;amp;IBCP_SCP) ;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH,&lt;/P&gt;&lt;P&gt;--Q.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Nov 2012 15:55:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-to-see-if-macro-exists/m-p/121143#M24826</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2012-11-08T15:55:15Z</dc:date>
    </item>
  </channel>
</rss>

