First, I will place my date into a Macro Variable.
NOTE: I find that date9. works great with IBM® Netezza® SQL and Transact-SQL. Use whichever format that works for the type of SQL you're executing.
data _null_; call symput('testDate',COMPRESS(put(today(),date9.))); ;RUN; %PUT &testDate;
My %PUT statement resolves to: 10MAR2017
Next, I want to run a PROC SQL Pass-through and resolve that Macro Variable inside to specify a date.
PROC SQL; CONNECT TO odbc AS alias (dsn=myServer user=userName password= pass); CREATE TABLE TableName AS SELECT * FROM connection to alias ( SELECT * FROM Database.schema.MyTable WHERE DateColumn = %bquote('&testDate') ); QUIT;
%bquote('&testDate') will resolve to '10MAR2017' when the code executes.