<?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 is empty in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-is-empty/m-p/268091#M53041</link>
    <description>&lt;P&gt;It should be noted that the WHERE condition&lt;/P&gt;
&lt;PRE&gt;clm_id in ( &amp;amp;clm. )&lt;/PRE&gt;
&lt;P&gt;fails also if macro variable CLM has been defined, but contains a null or blank string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case, however, &lt;FONT face="courier new,courier"&gt;%isblank(&amp;amp;clm.)&lt;/FONT&gt; resolves to 1, so that macro runStuff would incorrectly execute the "NOT Empty code" (presumably including the above WHERE condition).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To avoid this, one could initialize macro variable CLM (e.g., with a %LET, %LOCAL or %GLOBAL statement, as appropriate) and then use macro ISBLANK as has been suggested, but execute the "&lt;EM&gt;Empty&lt;/EM&gt; code" if it returns 1 and the "&lt;EM&gt;NOT Empty&lt;/EM&gt; code" if it returns 0.&amp;nbsp;This would also avoid the warning message about an unresolved apparent symbolic reference.&lt;/P&gt;</description>
    <pubDate>Tue, 03 May 2016 21:39:47 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2016-05-03T21:39:47Z</dc:date>
    <item>
      <title>Macro variable is empty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-is-empty/m-p/267895#M52977</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working on a sas code which I have created a macro variable to invoke with one conditiona and there sometimes the macro variable will be empty and that time it shows error in my log and stoping the job .I need to run the job also if the macro variable is empty and should create the dataset even though if the record is zero. How it is possible to invoke the macro if the macro variable is empty .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Manesh Kp&lt;/P&gt;</description>
      <pubDate>Tue, 03 May 2016 12:20:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-is-empty/m-p/267895#M52977</guid>
      <dc:creator>ambadi007</dc:creator>
      <dc:date>2016-05-03T12:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable is empty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-is-empty/m-p/267899#M52981</link>
      <description>&lt;P&gt;Attach your code please (simplified if possible).&lt;/P&gt;</description>
      <pubDate>Tue, 03 May 2016 12:32:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-is-empty/m-p/267899#M52981</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-05-03T12:32:14Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable is empty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-is-empty/m-p/267900#M52982</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think this have been answered in the past, check the links bellow:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A title="How to check if a macro variable is blan" href="https://communities.sas.com/t5/Base-SAS-Programming/How-to-check-if-a-macro-variable-is-blank/td-p/160327" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/How-to-check-if-a-macro-variable-is-blank/td-p/160327&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A title="check if macro variable is null" href="https://communities.sas.com/t5/Base-SAS-Programming/check-if-macro-variable-is-null/td-p/114506" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/check-if-macro-variable-is-null/td-p/114506&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;from stackOverflow:&lt;/P&gt;
&lt;P&gt;&lt;A title="Skip block of codes if macro variable is empty" href="http://stackoverflow.com/questions/24496087/skip-block-of-codes-if-macro-variable-is-empty" target="_blank"&gt;http://stackoverflow.com/questions/24496087/skip-block-of-codes-if-macro-variable-is-empty&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;also this&amp;nbsp;nice paper about the subject:&lt;/P&gt;
&lt;P&gt;&lt;A title="IS THIS MACRO PARAMETER BLANK?" href="http://support.sas.com/resources/papers/proceedings09/022-2009.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings09/022-2009.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;</description>
      <pubDate>Tue, 03 May 2016 12:35:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-is-empty/m-p/267900#M52982</guid>
      <dc:creator>BrunoSilva</dc:creator>
      <dc:date>2016-05-03T12:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable is empty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-is-empty/m-p/267902#M52983</link>
      <description>&lt;P&gt;Create a template, then insert or append records to it. &amp;nbsp;Table always exists then:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table RESULT (VAR1 char(200),VAR2 num);
  insert into RESULT select * from ADATASET;&lt;BR /&gt;/* Or */&lt;BR /&gt;  insert into RESULT select * from ADATASET where &amp;lt;condition&amp;gt;;
quit;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 May 2016 12:36:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-is-empty/m-p/267902#M52983</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-05-03T12:36:19Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable is empty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-is-empty/m-p/267903#M52984</link>
      <description>&lt;P&gt;Please show a small example of your problem (code).&amp;nbsp; Without seeing the macro code and data step code, it's hard to guess.&amp;nbsp; Please post the error from your log as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 May 2016 12:37:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-is-empty/m-p/267903#M52984</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2016-05-03T12:37:16Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable is empty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-is-empty/m-p/267911#M52989</link>
      <description>&lt;P&gt;I have created one macro variable and trying to extract from one databse giving condition as&lt;/P&gt;&lt;P&gt;where clm_id in (&amp;nbsp;&amp;amp;clm. ) since the &amp;amp;clm macro var is empty getting a warning message apparent symbolic reference clm&amp;nbsp; not resolved&lt;/P&gt;</description>
      <pubDate>Tue, 03 May 2016 12:58:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-is-empty/m-p/267911#M52989</guid>
      <dc:creator>ambadi007</dc:creator>
      <dc:date>2016-05-03T12:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable is empty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-is-empty/m-p/267915#M52990</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can do something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro isBlank(param);
%sysevalf(%superq(param)=,boolean)
%mend isBlank;

%macro runStuff;
%if %isblank(&amp;amp;clm.) = 1 %then %do;
...... NOT Empty code.......
%end;
%else %do;
......Empty code.......
%end;

%mend runStuff;
%runStuff;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Best regards&lt;/P&gt;</description>
      <pubDate>Tue, 03 May 2016 13:09:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-is-empty/m-p/267915#M52990</guid>
      <dc:creator>BrunoSilva</dc:creator>
      <dc:date>2016-05-03T13:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable is empty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-is-empty/m-p/268091#M53041</link>
      <description>&lt;P&gt;It should be noted that the WHERE condition&lt;/P&gt;
&lt;PRE&gt;clm_id in ( &amp;amp;clm. )&lt;/PRE&gt;
&lt;P&gt;fails also if macro variable CLM has been defined, but contains a null or blank string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case, however, &lt;FONT face="courier new,courier"&gt;%isblank(&amp;amp;clm.)&lt;/FONT&gt; resolves to 1, so that macro runStuff would incorrectly execute the "NOT Empty code" (presumably including the above WHERE condition).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To avoid this, one could initialize macro variable CLM (e.g., with a %LET, %LOCAL or %GLOBAL statement, as appropriate) and then use macro ISBLANK as has been suggested, but execute the "&lt;EM&gt;Empty&lt;/EM&gt; code" if it returns 1 and the "&lt;EM&gt;NOT Empty&lt;/EM&gt; code" if it returns 0.&amp;nbsp;This would also avoid the warning message about an unresolved apparent symbolic reference.&lt;/P&gt;</description>
      <pubDate>Tue, 03 May 2016 21:39:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-is-empty/m-p/268091#M53041</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-05-03T21:39:47Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable is empty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-is-empty/m-p/422515#M103902</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a related question. I involving the macro as below.&lt;/P&gt;&lt;P&gt;But seems SAS keep checking validation of the null macro variable in STRIP function, ignoring any condition rules like IF...THEN. How can I skip errors like that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data work._tst1;&lt;BR /&gt;input sex $ ;&lt;BR /&gt;datalines;&lt;BR /&gt;0&lt;BR /&gt;1&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let sex = sex ;&lt;BR /&gt;%let sexOrienta = ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro isBlank(param);&lt;BR /&gt;%sysevalf(%superq(param)=,boolean)&lt;BR /&gt;%mend isBlank;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data work._tst2;&lt;BR /&gt;set work._tst1;&lt;BR /&gt;has_sexOrienta = %isblank(&amp;amp;sexOrienta); *&amp;lt;--this works fine;&lt;BR /&gt;if %isblank(&amp;amp;sexOrienta)=1 then sexOrienta = 'empty'; *&amp;lt;--this works fine if omit the below line;&lt;BR /&gt;else sexOrienta=strip(&amp;amp;sexOrienta) ; *&amp;lt;--this line keep causing errors due to strip(null) problem, even condition is not met;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Had been searching different key words for solutions, but couldn't find any. Thx a lot.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Dec 2017 22:08:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-is-empty/m-p/422515#M103902</guid>
      <dc:creator>YoungShore</dc:creator>
      <dc:date>2017-12-19T22:08:04Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable is empty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-is-empty/m-p/422537#M103913</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have no SAS to test but I think your problem is that you are mixing datastep if with the macro.&lt;/P&gt;
&lt;P&gt;Remember&amp;nbsp;macro will be solved&amp;nbsp;first and&amp;nbsp;datastep if only will use the resolved result of the macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After macro resolve will be something like below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work._tst2;
    set work._tst1;
    has_sexOrienta = 1; 

    if 1=1 then sexOrienta = 'empty';
    else sexOrienta=strip() ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and as you see strip() will give the error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;</description>
      <pubDate>Tue, 19 Dec 2017 23:48:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-is-empty/m-p/422537#M103913</guid>
      <dc:creator>BrunoSilva</dc:creator>
      <dc:date>2017-12-19T23:48:11Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable is empty</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-is-empty/m-p/422647#M103928</link>
      <description>&lt;P&gt;Please dont re-open an old post which has been solved.&amp;nbsp; Post a new question.&amp;nbsp; Also, don't use macro when it is not needed, there is a base SAS function called missing() which will test this for you:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  sexorienta=ifc(missing(sex),"empty","");
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Dec 2017 09:17:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-is-empty/m-p/422647#M103928</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-12-20T09:17:03Z</dc:date>
    </item>
  </channel>
</rss>

