title: Parameterised SQL WHERE statement and SAS Macro Language problems
body: <p>I have a piece of code that has parameterised a hundred or so similar, but not identical SQL statements I need to generate data I require. The parameterisation works fine apart from the where statements. I am passing in a macro string of the following format:</p>
  
  <pre><code>where PERIOD_LAST_DTTM = '31DEC2017:23:59:59'dt
    and myvar1 = 1 and myvar2 &lt; 0
    and myvar3 in ('SOME STRING', 'SOME OTHER STRING')  
  </code></pre>
  
  <p>...with the following syntax:</p>
  
  <pre><code>%if %eval(&amp;inn_sel_var. ^= &amp;comp_var2.) %then %do;
  
          &amp;inn_sel_var.
  
  %end;   
  </code></pre>
  
  <p>/<em>&amp;inn_sel_var is where string &amp;comp_var2 = NULL</em>/</p>
  
  <p>...but am getting the following error:</p>
  
  <pre><code>ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: 
         where PERIOD_LAST_DTTM = '31DEC2017:23:59:59'dt and myvar1 = 1 and myvar2 &lt; 0 and myvar3 in ('SOME STRING', 'SOME OTHER STRING')                                                                                    
  
  
               ^= NULL 
  ERROR: %EVAL function has no expression to evaluate, or %IF statement has no condition.
  ERROR: The macro MODEL_CHECKS will stop executing.
  </code></pre>
  
  <p>...I have tried using %STR, %SUPERQ, %QUOTE, %BQUOTE, %NRQUOTE, %NRBQUOTE and %UNQUOTE, but I keep on hitting errors. Could someone please advise what I need to do in order for feed my parameterised where statements in correctly?</p>
  
  <p>Thanks</p>