Convert date into varchar with sas

261 Views Asked by At

I really hope you can assist.

When I run this code:

libname odbc ### user='abc' password='****' dsn='bleh' schema='dbo';


%let date=%sysfunc(intnx(day,%sysfunc(today()),-1,b),yymmddd10.);
%put &date.;

run;

It works!

But if I run it with the call execute I get this error – it reads from sql – yet the date in sql is varchar:

data _null_;
set odbc.SQLTableName;
if ((date= &date.) and (dateComplete ne .))then call execute("%include 'path';"); 

 run;

dateComplete=Jun 10 2015 1:54PM _ERROR_=1 _N_=1

I am looking for a way to convert my date.

So it reads today()-1 (Technically yesterday’s date)

YOUR HELP WILL BE GREATLY APPRECIATED!!!

1

There are 1 best solutions below

1
On

Shouldn't you be using single quotes instead of double quotes? As you don't want your macro to be executed before the data step ends?

call execute("%include 'path';"); 

Try:

call execute('%include "path";');