title: Passing sas variable into a sql pass through statement
body: <p>Using SAS I'm pulling data from a SQL data base using a pass through for speed as the DB's are quite large. The below code works as expected.</p>
  
  <pre><code>%let expectdate1 = '2013-07-03';*/
  
  proc sql;
  
  connect to ***** as abc (tdpid=***** user='****' password='*****' );
  create table Searched_data as
  select * from connection to dss(
  
  SELECT  *
  FROM  database.tablename
  WHERE CAPTURE_DT &gt;= '2013-07-01' and CAPTURE_DT &lt;= &amp;expectdate1
  
  );
  disconnect from abc;
  quit;
  </code></pre>
  
  <p>The issues arises when I wan to have expectate1 parameterised.</p>
  
  <p>so I replace </p>
  
  <pre><code>%let expectdate1 = '2013-07-03';*/
  </code></pre>
  
  <p>with</p>
  
  <pre><code>%let expectdate1 = put(Date(),YYMMDD10.);
  </code></pre>
  
  <p>This doesnt work and the error Im getting is something like</p>
  
  <pre><code>....WHERE CAPTURE_DT &gt;= '2013-07-01' and CAPTURE_DT &lt;= put(Date(),YYMMDD10) .....
  </code></pre>
  
  <p>So its not evaluating my date code and instead its passing the actual code to SQL and not the resultant string.</p>