<?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 Using Boolean parameters in a stored process in Developers</title>
    <link>https://communities.sas.com/t5/Developers/Using-Boolean-parameters-in-a-stored-process/m-p/1507#M1584</link>
    <description>I was having some problems getting a SP to work with a Boolean Parameter.  I have made up a mock example to simplify my code.  It seem that I always return a=1 and b=1 whether my boolean value is true or false? here is my code. Thank you in advance for your help. Dan&lt;BR /&gt;
%Global b1;&lt;BR /&gt;
&lt;BR /&gt;
data fun;&lt;BR /&gt;
  a = 0;&lt;BR /&gt;
  b = 0;&lt;BR /&gt;
data fun;&lt;BR /&gt;
	set fun;&lt;BR /&gt;
	if &amp;amp;b1=true then&lt;BR /&gt;
		do;&lt;BR /&gt;
		a = 1;&lt;BR /&gt;
		b = 1;&lt;BR /&gt;
		end;&lt;BR /&gt;
proc print;&lt;BR /&gt;
run;</description>
    <pubDate>Thu, 05 Oct 2006 20:48:58 GMT</pubDate>
    <dc:creator>Dan_S</dc:creator>
    <dc:date>2006-10-05T20:48:58Z</dc:date>
    <item>
      <title>Using Boolean parameters in a stored process</title>
      <link>https://communities.sas.com/t5/Developers/Using-Boolean-parameters-in-a-stored-process/m-p/1507#M1584</link>
      <description>I was having some problems getting a SP to work with a Boolean Parameter.  I have made up a mock example to simplify my code.  It seem that I always return a=1 and b=1 whether my boolean value is true or false? here is my code. Thank you in advance for your help. Dan&lt;BR /&gt;
%Global b1;&lt;BR /&gt;
&lt;BR /&gt;
data fun;&lt;BR /&gt;
  a = 0;&lt;BR /&gt;
  b = 0;&lt;BR /&gt;
data fun;&lt;BR /&gt;
	set fun;&lt;BR /&gt;
	if &amp;amp;b1=true then&lt;BR /&gt;
		do;&lt;BR /&gt;
		a = 1;&lt;BR /&gt;
		b = 1;&lt;BR /&gt;
		end;&lt;BR /&gt;
proc print;&lt;BR /&gt;
run;</description>
      <pubDate>Thu, 05 Oct 2006 20:48:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Using-Boolean-parameters-in-a-stored-process/m-p/1507#M1584</guid>
      <dc:creator>Dan_S</dc:creator>
      <dc:date>2006-10-05T20:48:58Z</dc:date>
    </item>
    <item>
      <title>Re: Using Boolean parameters in a stored process</title>
      <link>https://communities.sas.com/t5/Developers/Using-Boolean-parameters-in-a-stored-process/m-p/1508#M1585</link>
      <description>I would think that it's rather a macro logic problem than a stored process problem.&lt;BR /&gt;
When you write a SAS statement like the IF statement, it is not processed by the macro facility.&lt;BR /&gt;
Hence what you write is either :&lt;BR /&gt;
&lt;BR /&gt;
IF true = true THEN DO ; etc.&lt;BR /&gt;
&lt;BR /&gt;
or&lt;BR /&gt;
&lt;BR /&gt;
IF false = true THEN DO ; etc.&lt;BR /&gt;
&lt;BR /&gt;
From a SAS (and not macro) point of view, this means you are comparing values for variables named TRUE or FALSE. Not that you're comparing text strings "TRUE" or "FALSE", which would require quotes around the value itself.&lt;BR /&gt;
As the variables TRUE and FALSE don't exist in your dataset, they are created with missing values (you should see them in the printed output). Your condition, in every case, ends up as :&lt;BR /&gt;
IF . = . THEN ...&lt;BR /&gt;
which is always true.&lt;BR /&gt;
&lt;BR /&gt;
I would transform your program into :&lt;BR /&gt;
&lt;BR /&gt;
%Global b1;&lt;BR /&gt;
data fun;&lt;BR /&gt;
a = 0;&lt;BR /&gt;
b = 0;&lt;BR /&gt;
data fun;&lt;BR /&gt;
set fun;&lt;BR /&gt;
if "%UPCASE(&amp;amp;b1)"="TRUE" then&lt;BR /&gt;
do;&lt;BR /&gt;
a = 1;&lt;BR /&gt;
b = 1;&lt;BR /&gt;
end;&lt;BR /&gt;
proc print;&lt;BR /&gt;
run; &lt;BR /&gt;
&lt;BR /&gt;
another solution is to use the macro-IF, for which everything is just plain text and then, no quotes needed anywhere.&lt;BR /&gt;
&lt;BR /&gt;
%Global b1;&lt;BR /&gt;
&lt;BR /&gt;
data fun;&lt;BR /&gt;
a = 0;&lt;BR /&gt;
b = 0;&lt;BR /&gt;
data fun;&lt;BR /&gt;
set fun;&lt;BR /&gt;
%if &amp;amp;b1=true %then&lt;BR /&gt;
%do;&lt;BR /&gt;
a = 1;&lt;BR /&gt;
b = 1;&lt;BR /&gt;
%end;&lt;BR /&gt;
proc print;&lt;BR /&gt;
run;</description>
      <pubDate>Mon, 16 Oct 2006 12:56:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Using-Boolean-parameters-in-a-stored-process/m-p/1508#M1585</guid>
      <dc:creator>Olivier</dc:creator>
      <dc:date>2006-10-16T12:56:08Z</dc:date>
    </item>
  </channel>
</rss>

