<?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 Setting which section of SAS code to run with a %LET variable in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Setting-which-section-of-SAS-code-to-run-with-a-LET-variable/m-p/151600#M39918</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;I want to set a variable called purpose, e.g.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%LET PURPOSE = CHANGE ; /* PURPOSE can only take the words CHANGE or PROFIT */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it is set as CHANGE I want it to skip a bit of code and run a bit of code after it.&lt;/P&gt;&lt;P&gt;If it is set as PROFIT I want it to skip the last bit of code and run the code before it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How do I do this within the same Sas Program without having it call a separate SAS program using a call function?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 06 Aug 2014 15:47:38 GMT</pubDate>
    <dc:creator>brophymj</dc:creator>
    <dc:date>2014-08-06T15:47:38Z</dc:date>
    <item>
      <title>Setting which section of SAS code to run with a %LET variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Setting-which-section-of-SAS-code-to-run-with-a-LET-variable/m-p/151600#M39918</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;I want to set a variable called purpose, e.g.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%LET PURPOSE = CHANGE ; /* PURPOSE can only take the words CHANGE or PROFIT */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it is set as CHANGE I want it to skip a bit of code and run a bit of code after it.&lt;/P&gt;&lt;P&gt;If it is set as PROFIT I want it to skip the last bit of code and run the code before it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How do I do this within the same Sas Program without having it call a separate SAS program using a call function?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Aug 2014 15:47:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Setting-which-section-of-SAS-code-to-run-with-a-LET-variable/m-p/151600#M39918</guid>
      <dc:creator>brophymj</dc:creator>
      <dc:date>2014-08-06T15:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: Setting which section of SAS code to run with a %LET variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Setting-which-section-of-SAS-code-to-run-with-a-LET-variable/m-p/151601#M39919</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One way to do such conditional processing&amp;nbsp; is with a macro:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;%macro doit(purpose=);
&amp;nbsp; %if &amp;amp;purpose=CHANGE %then %do;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *SAS code here;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; %end;
&amp;nbsp; %else %if &amp;amp;purpose=PROFIT %then %do;
&amp;nbsp;&amp;nbsp;&amp;nbsp; *SAS code here;
&amp;nbsp; %end;
%mend doit;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then can call the macro like:&lt;/P&gt;&lt;P&gt;%doit(purpose=CHANGE)&lt;/P&gt;&lt;P&gt;%doit(purpose=PROFIT)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or if you like having the global macro variable to use as a switch, call like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%doit(purpose=&amp;amp;purpose)&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>Wed, 06 Aug 2014 15:55:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Setting-which-section-of-SAS-code-to-run-with-a-LET-variable/m-p/151601#M39919</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2014-08-06T15:55:59Z</dc:date>
    </item>
  </channel>
</rss>

