<?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: Getting %if to evaluate if a macro variable is BETWEEN two numbers in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Getting-if-to-evaluate-if-a-macro-variable-is-BETWEEN-two/m-p/633091#M187790</link>
    <description>Thanks!</description>
    <pubDate>Wed, 18 Mar 2020 21:35:26 GMT</pubDate>
    <dc:creator>mdavidson</dc:creator>
    <dc:date>2020-03-18T21:35:26Z</dc:date>
    <item>
      <title>Getting %if to evaluate if a macro variable is BETWEEN two numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-if-to-evaluate-if-a-macro-variable-is-BETWEEN-two/m-p/632079#M187353</link>
      <description>&lt;P&gt;Hi all --&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to find the best way to accomplish the below code. I want the code to return option C, but in the log, it will return both options B and C. I realize the %if is not able to evaluate a situation with 2 criteria, but what would be the best way to modify the below code to return only "Option C" in this example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some additional background info on this, I'm using this to run a stored process. Basically, if the results are less than 10,000 I want to return data to the screen, if the data is between 10,000 and 100,000 I will email. If it's over 100,000 I want to stop the stored process and tell the user to adjust their query.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let g_nobs=100000;
%macro run_process;
%if &amp;amp;g_nobs = 0 %then %do;
	%put Option A;
%end;

/*WANT*/
%if 1 &amp;lt; &amp;amp;g_nobs &amp;lt;=10000 %then %do;
	%put Option B;
%end;

%if &amp;amp;g_nobs &amp;gt; 10000 %then %do;
	%put Option C;
%end;

%mend run_process;

%run_process;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Mar 2020 21:16:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-if-to-evaluate-if-a-macro-variable-is-BETWEEN-two/m-p/632079#M187353</guid>
      <dc:creator>mdavidson</dc:creator>
      <dc:date>2020-03-13T21:16:15Z</dc:date>
    </item>
    <item>
      <title>Re: Getting %if to evaluate if a macro variable is BETWEEN two numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-if-to-evaluate-if-a-macro-variable-is-BETWEEN-two/m-p/632081#M187354</link>
      <description>&lt;P&gt;Use Mutually exclusive conditions :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let g_nobs=100000;

%macro run_process;
	%if &amp;amp;g_nobs = 0 %then
		%do;
			%put Option A;
		%end;

	/*WANT*/
	%if %eval(1 &amp;lt; &amp;amp;g_nobs &amp;lt;=10000) %then
		%do;
			%put Option B;
		%end;
	%else %if %eval(&amp;amp;g_nobs &amp;gt; 10000) %then
		%do;
			%put Option C;
		%end;
%mend run_process;

%run_process;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;26         %let g_nobs=100000;
27         
28         %macro run_process;
29         	%if &amp;amp;g_nobs = 0 %then
30         		%do;
31         			%put Option A;
32         		%end;
33         
34         	/*WANT*/
35         	%if %eval(1 &amp;lt; &amp;amp;g_nobs &amp;lt;=10000) %then
36         		%do;
37         			%put Option B;
38         		%end;
39         	%else %if %eval(&amp;amp;g_nobs &amp;gt; 10000) %then
40         		%do;
41         			%put Option C;
42         		%end;
43         %mend run_process;
44         
45         %run_process;
Option B
&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Mar 2020 21:36:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-if-to-evaluate-if-a-macro-variable-is-BETWEEN-two/m-p/632081#M187354</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2020-03-13T21:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: Getting %if to evaluate if a macro variable is BETWEEN two numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-if-to-evaluate-if-a-macro-variable-is-BETWEEN-two/m-p/632088#M187360</link>
      <description>&lt;P&gt;Your syntax for option B is not supported.&amp;nbsp; This is correct.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if 1 &amp;lt; &amp;amp;g_nobs and &amp;amp;g_nobs &amp;lt;=10000 %then %do;
	%put Option B;
   %end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Mar 2020 22:16:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-if-to-evaluate-if-a-macro-variable-is-BETWEEN-two/m-p/632088#M187360</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2020-03-13T22:16:03Z</dc:date>
    </item>
    <item>
      <title>Re: Getting %if to evaluate if a macro variable is BETWEEN two numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-if-to-evaluate-if-a-macro-variable-is-BETWEEN-two/m-p/632133#M187377</link>
      <description>&lt;P&gt;Since 9.4M5 it is possible to use %if in open code, so you can do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let g_nobs=100000;

%if &amp;amp;g_nobs = 0 %then %do;
	%put Option A;
%end;

%if 1 &amp;lt; &amp;amp;g_nobs and &amp;amp;g_nobs &amp;lt;= 10000 %then %do;
	%put Option B;
%end;

%if &amp;amp;g_nobs &amp;gt; 10000 %then %do;
	%put Option C;
%end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 14 Mar 2020 09:50:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-if-to-evaluate-if-a-macro-variable-is-BETWEEN-two/m-p/632133#M187377</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-03-14T09:50:42Z</dc:date>
    </item>
    <item>
      <title>Re: Getting %if to evaluate if a macro variable is BETWEEN two numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-if-to-evaluate-if-a-macro-variable-is-BETWEEN-two/m-p/633091#M187790</link>
      <description>Thanks!</description>
      <pubDate>Wed, 18 Mar 2020 21:35:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-if-to-evaluate-if-a-macro-variable-is-BETWEEN-two/m-p/633091#M187790</guid>
      <dc:creator>mdavidson</dc:creator>
      <dc:date>2020-03-18T21:35:26Z</dc:date>
    </item>
  </channel>
</rss>

