<?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: Condition based skip the block of code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Condition-based-skip-the-block-of-code/m-p/545782#M151053</link>
    <description>&lt;P&gt;There are a few ways to check for a non-null value in a macro variable.&amp;nbsp; The one I like is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%if %length(&amp;amp;date) &amp;gt; 0 %then %do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could insert that in the middle of your macro (with a matching %end statement at the end of the conditional code).&lt;/P&gt;</description>
    <pubDate>Mon, 25 Mar 2019 12:39:27 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2019-03-25T12:39:27Z</dc:date>
    <item>
      <title>Condition based skip the block of code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Condition-based-skip-the-block-of-code/m-p/545776#M151048</link>
      <description>&lt;P&gt;I am looking to skip block of code based on some condition. Like if user does not enter date in the parameter of macro the following code won't run.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%macro test(final_File,date);

/*Other macro*/

/****I want to skip the following Code if user doesn't enter date in parameter*****/

insert into  &amp;amp;final_File._checkpoints
set Checkpoints="Min Date",
Total_Count=(select Count(&amp;amp;date.)  from &amp;amp;final_File.),
Date_Check=(select min(&amp;amp;date.) format date9. as min_date from &amp;amp;final_File.),
comment="Min date of record",
Update_Date=today();
run;

/*Other macro*/

%mend;&lt;/PRE&gt;&lt;P&gt;same as we had in VBA,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; If date="" then goto xx:

Block of code which will be missed if condition matches here

xx:
run another code&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Mar 2019 12:30:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Condition-based-skip-the-block-of-code/m-p/545776#M151048</guid>
      <dc:creator>Srigyan</dc:creator>
      <dc:date>2019-03-25T12:30:29Z</dc:date>
    </item>
    <item>
      <title>Re: Condition based skip the block of code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Condition-based-skip-the-block-of-code/m-p/545780#M151051</link>
      <description>&lt;P&gt;Depending on what is needed I would probably use&amp;nbsp; %if - %then - %else block&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And in the first %if evaluate your inputs for validity.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example from the link below&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* capture conditional logic in macro */
%macro SummarizeIfExists();
 %if %sysfunc(exist(work.result)) %then
  %do;
    proc means data=work.result;
    run;
  %end; 
%else
  %do;
    %PUT WARNING: Missing WORK.RESULT - report process skipped.;
  %end;
%mend;
 
/* call the macro */
%SummarizeIfExists();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Really broken down here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sasdummy/2018/07/05/if-then-else-sas-programs/" target="_blank" rel="noopener"&gt;https://blogs.sas.com/content/sasdummy/2018/07/05/if-then-else-sas-programs/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2019 12:35:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Condition-based-skip-the-block-of-code/m-p/545780#M151051</guid>
      <dc:creator>Eric_D</dc:creator>
      <dc:date>2019-03-25T12:35:29Z</dc:date>
    </item>
    <item>
      <title>Re: Condition based skip the block of code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Condition-based-skip-the-block-of-code/m-p/545782#M151053</link>
      <description>&lt;P&gt;There are a few ways to check for a non-null value in a macro variable.&amp;nbsp; The one I like is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%if %length(&amp;amp;date) &amp;gt; 0 %then %do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could insert that in the middle of your macro (with a matching %end statement at the end of the conditional code).&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2019 12:39:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Condition-based-skip-the-block-of-code/m-p/545782#M151053</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-03-25T12:39:27Z</dc:date>
    </item>
  </channel>
</rss>

