<?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: %If  %then %do in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/If-then-do/m-p/359642#M84584</link>
    <description>&lt;P&gt;You haven't mentioned what is not running, I will take a punt and state it is because you are using a variable i, rather than the macro variable &amp;amp;i. &amp;nbsp;So your code should look like this (note also I changed a few other bits for readability:&lt;/P&gt;
&lt;PRE&gt;data toto;
  input u;
cards;
5
5
9
8
17
14
15
;
run;

%macro p (i);
  %if &amp;amp;i. &amp;gt; 5 and &amp;amp;i. &amp;lt; 10 %then %do;
    data titi;
      set toto;
    run;
    proc print; 
    run;
  %end;
%mend;
%p (9);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 18 May 2017 13:09:53 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-05-18T13:09:53Z</dc:date>
    <item>
      <title>%If  %then %do</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-then-do/m-p/359638#M84583</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi,&lt;BR /&gt;In a more complex program, I need to set 2 conditions in my "if". I need to keep a macro. But the "&amp;amp;" and "and" do not work.&lt;/P&gt;&lt;P&gt;Do you have a solution thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a simple program:&lt;BR /&gt;data toto;&lt;BR /&gt;input u;&lt;BR /&gt;cards;&lt;BR /&gt;5&lt;BR /&gt;5&lt;BR /&gt;9&lt;BR /&gt;8&lt;BR /&gt;17&lt;BR /&gt;14&lt;BR /&gt;15&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;%macro p (i);&lt;BR /&gt;%if i&amp;gt;5 &lt;U&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;and&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/U&gt; i&amp;lt;10 %then %do;&lt;BR /&gt;data titi;&lt;BR /&gt;set toto;&lt;BR /&gt;run;&lt;BR /&gt;proc print; run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;%p (9)&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2017 13:05:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-then-do/m-p/359638#M84583</guid>
      <dc:creator>WilliamB</dc:creator>
      <dc:date>2017-05-18T13:05:33Z</dc:date>
    </item>
    <item>
      <title>Re: %If  %then %do</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-then-do/m-p/359642#M84584</link>
      <description>&lt;P&gt;You haven't mentioned what is not running, I will take a punt and state it is because you are using a variable i, rather than the macro variable &amp;amp;i. &amp;nbsp;So your code should look like this (note also I changed a few other bits for readability:&lt;/P&gt;
&lt;PRE&gt;data toto;
  input u;
cards;
5
5
9
8
17
14
15
;
run;

%macro p (i);
  %if &amp;amp;i. &amp;gt; 5 and &amp;amp;i. &amp;lt; 10 %then %do;
    data titi;
      set toto;
    run;
    proc print; 
    run;
  %end;
%mend;
%p (9);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2017 13:09:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-then-do/m-p/359642#M84584</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-05-18T13:09:53Z</dc:date>
    </item>
    <item>
      <title>Re: %If  %then %do</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-then-do/m-p/359643#M84585</link>
      <description>&lt;P&gt;&lt;SPAN&gt;%if &amp;amp;i&amp;gt;5 &lt;/SPAN&gt;&lt;U&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;and&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/U&gt;&lt;SPAN&gt;&amp;nbsp;&amp;amp;i&amp;lt;10 %then %do;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2017 13:10:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-then-do/m-p/359643#M84585</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-05-18T13:10:29Z</dc:date>
    </item>
  </channel>
</rss>

