<?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 Macro - Conditionally Process some code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-Conditionally-Process-some-code/m-p/749514#M235537</link>
    <description>&lt;P&gt;The pseudo code below will demonstrate what I would like to do.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Assume I have a macro of the sort:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MyMacro(Part1YesOrNO, Part2YesOrNO);&amp;nbsp;
   Some code representing "Part 1"; 
      .
      . 
      . 
   Some code representing "Part 2"; 
%mend MyMacro; 

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now, if the user types in:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MyMacro(Yes, Yes);&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;both parts of the Macro should be run.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the user types in:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MyMacro(Yes, No);&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Only part 1 of the Macro should be run.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Any advice of how I could achieve this kind of functionality?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 22 Jun 2021 13:07:10 GMT</pubDate>
    <dc:creator>SasStatistics</dc:creator>
    <dc:date>2021-06-22T13:07:10Z</dc:date>
    <item>
      <title>Macro - Conditionally Process some code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Conditionally-Process-some-code/m-p/749514#M235537</link>
      <description>&lt;P&gt;The pseudo code below will demonstrate what I would like to do.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Assume I have a macro of the sort:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MyMacro(Part1YesOrNO, Part2YesOrNO);&amp;nbsp;
   Some code representing "Part 1"; 
      .
      . 
      . 
   Some code representing "Part 2"; 
%mend MyMacro; 

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now, if the user types in:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MyMacro(Yes, Yes);&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;both parts of the Macro should be run.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the user types in:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MyMacro(Yes, No);&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Only part 1 of the Macro should be run.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Any advice of how I could achieve this kind of functionality?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jun 2021 13:07:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Conditionally-Process-some-code/m-p/749514#M235537</guid>
      <dc:creator>SasStatistics</dc:creator>
      <dc:date>2021-06-22T13:07:10Z</dc:date>
    </item>
    <item>
      <title>Re: Macro - Conditionally Process some code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Conditionally-Process-some-code/m-p/749516#M235539</link>
      <description>&lt;P&gt;%macro mymacro(part1yesorno, part2yesorno);&lt;/P&gt;&lt;P&gt;&amp;nbsp; %if %upcase(%substr(&amp;amp;part1yesorno, 1, 1)) = Y %then %do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; /* your part1 code goes here */&lt;/P&gt;&lt;P&gt;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %if %upcase(%substr(&amp;amp;part2yesorno, 1, 1) = Y %then %do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; /* your part2 code goes here */&lt;/P&gt;&lt;P&gt;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%mymacro(Yes, No);&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jun 2021 13:15:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Conditionally-Process-some-code/m-p/749516#M235539</guid>
      <dc:creator>tbellmer_wf</dc:creator>
      <dc:date>2021-06-22T13:15:55Z</dc:date>
    </item>
    <item>
      <title>Re: Macro - Conditionally Process some code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Conditionally-Process-some-code/m-p/749517#M235540</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MyMacro(Part1YesOrNO, Part2YesOrNO); 
    %if %upcase(&amp;amp;part1yesorno)=YES %then %do;
   Some code representing "Part 1"; 
    %end;
      . 
   %if %upcase(&amp;amp;part2yesorno)=YES %then %do;   . 
   Some code representing "Part 2"; 
    %end;
%mend MyMacro; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hint: don't use such long variable names unless they are absolutely necessary, I would create the macro as follows&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro mymacro(part1,part2);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;unless you are a much better typist than I am, I find shorter name that still have meaning a much better approach, its less typing and less chance for error. Also, I prefer values of Y or N to Yes or No, again simplicity and less typing and less chance for error.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jun 2021 13:17:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Conditionally-Process-some-code/m-p/749517#M235540</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-06-22T13:17:59Z</dc:date>
    </item>
    <item>
      <title>Re: Macro - Conditionally Process some code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Conditionally-Process-some-code/m-p/749520#M235543</link>
      <description>&lt;P&gt;Consider:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MyMacro(Part1YesOrNO, Part2YesOrNO); 
  %if &amp;amp;part1yesorno=Yes %then %do;
     *Some code representing "Part 1"; 
  %end;
  %if &amp;amp;part2yesorno=Yes %then %do;
     *Some code representing "Part 2"; 
  %end;
%mend MyMacro; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 Jun 2021 13:19:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Conditionally-Process-some-code/m-p/749520#M235543</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-06-22T13:19:37Z</dc:date>
    </item>
  </channel>
</rss>

