在远程会话中,在远程会话中引用变量很麻烦。
我要实现的是动态日期查询。目前,脚本与静态WHERE语句配合正常。但是,我尝试引用宏变量的所有内容,都以一种或另一种方式失败。
这有效:
WHERE SDD LIKE '2018-09%'
但这不是:
WHERE SDD LIKE '2018-"&monthn."%'
or
WHERE SDD LIKE '2018-"monthn"%'
or
WHERE SDD LIKE %str(%')2018-&monthn.%str(%')
感谢所有建议
这或多或少是所有相关代码:
*-------------------------------------------------------------------;
* LOGIN TO zOS ;
*-------------------------------------------------------------------;
%let zos = ********;
signon zos userid=&userid. password=&passw.;
*-------------------------------------------------------------------;
* PREPARE LOCAL VARIABLES FOR TRANSFER TO REMOTE ;
*-------------------------------------------------------------------;
%SYSLPUT MONTHN = &monthn; /* MONTHN = 11 */
*-------------------------------------------------------------------;
* OPEN CONNECTION, DOWNLOAD FLIGHTS, CLOSE CONNECTION AND SIGNOFF ;
*-------------------------------------------------------------------;
rsubmit; /* REMOTE COMPUTING START */
%PUT &MONTHN; /* GET LOCAL VARIABLES */
----
Many lines of settings up the
wintel/sql connection
----
%SYSLPUT MONTHN = &monthn;
rsubmit;
%PUT &MONTHN; /* GET LOCAL VARIABLES */
proc sql dquote=sas;
create table TKLM1WINTEL as
SELECT *
FROM tables
WHERE SDD LIKE '2018-"&monthn."%'
/* WHERE SDD LIKE '2018-09%' */
PROC download data=TKLM1WINTEL out=DBFILE;
RUN;
endrsubmit;
endrsubmit; /* REMOTE COMPUTING END */
signoff;
答案 0 :(得分:0)
答案 1 :(得分:0)
类似的东西应该起作用。
data abc;
input id sdd $8.;
datalines;
1 2018-091
2 2018-081
;
%let month =09;
proc sql;
select * from abc
where sdd like "2018-&month.%";