Reputation: 5173
How to read macro variable as a character in SAS SQL pass-through
My goal is to put "one" as the only value in var3 , but now i get
"unknown column one"
%macro test(notvar=)
proc sql;
connect to odbc as conn (datasrc=x user=&user1. password=&pwd1.);
create table ¬var. (compress=no) as select * from connection to conn
(
select var1, var2,
¬var. as var3
from table1
);
disconnect from conn;
quit;
%mend test;
%test(notvar=one);
Upvotes: 1
Views: 2937
Reputation: 1511
Haven't tested though. I think you can put the macro variable as value of column like:
select var1, var2,
"¬var" as var3
from table1
or
select var1, var2,
symget('notvar') as var3
from table1
If no quotation mark or function for fetching macro variable value is specified, the selected object ("one" here in your case) is regarded as a column in the original table. So you get error for there is no such column.
Upvotes: 2