I am trying to insert a row into a SAS data set using PROC SQL and the values of existing macro variables but I'm getting the standard syntax error message. Here is an example of the code that fails:
%let viewname=MKTVIEWS.imei_ref;
%let xrc=0;
%let xmsg= ;
proc sql;
create table results (viewname char(40), xrc numeric, xmsg char(200));
insert into results (viewname, xrc, xmsg)
values ( %str(%')&viewname%str(%')
, &xrc
, %str(%')%superq(xmsg)%str(%') );
quit;
Here is the error message:
ERROR 22-322: Syntax error, expecting one of the following: a quoted string,
a numeric constant, a datetime constant, a missing value, +, -, MISSING, NULL,
USER.
Running the program without the two character macro variables works fine:
proc sql;
create table results (viewname char(40), xrc numeric, xmsg char(200));
insert into results (viewname, xrc, xmsg)
values ( 'MKTVIEWS.imei_ref'
, &xrc
, '' );
quit;
Clearly I'm missing something about macro quoting or something similar. I even tried using temporary macro variables rather than embedding those %STR
calls to create a quoted string, but that didn't work either.