我需要在下面的 SQL 传递代码中使用宏变量,但不断收到错误,我不知道如何修复它!
%let mon1 = 201209;
proc sql;
/*Connection String*/
connect to odbc as sqldata (noprompt="uid=dr;pwd=raven;dsn=FinanceDW;") ;
create table output1 as /*This will create a SAS data set*/
select * /*this will select all from the command below and insert into the SAS dataset*/
from connection to sqldata
( /*Insert SQL CODE below - it can only use SQL any SAS code will cause it to fail*/
select top 10 *
from "AUS_&mon1._FCM15.dbo.contract"
);/*End SQL code*/
disconnect from sqldata;/*Close connection*/
quit;
然后我收到以下错误(从日志中提取):
23 select top 10 *
24 from "AUS_&mon1._FCM15.dbo.contract"
25
26 );
ERROR: CLI describe error: [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name
'AUS_201209_FCM15.dbo.contract'. : [Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s)
could not be prepared.
我需要从中获取数据的实际表称为 AUS_201209_FCM15 所以我不知道问题是什么?