Two macro variables are defined for table schema and table name and they are used in the proc sql statement in SAS (postgresql interface to Amazon RedShift), sql statement can't be read correctly.
%let table_schema = 'sales';
%let table_name = 'summary_table';
proc sql;
connect to ODBC(DSN='redshift_db', user=masteruser password='*pwd');
create table column_names as
select * from connection to odbc(
select distinct(column_name) as col_name from information_schema.columns where table_schema = &table_schema and table_name = &table_name;
);
create table dt as
select * from connection to odbc(
select * from &table_schema..&table_name;
);
QUIT;
The first table creation throws an error:
ERROR: CLI describe error: ERROR: column "summary_table" does not exist in columns;
The "summary_table" actually exists.
The second table creation throws an error:
ERROR: CLI describe error: ERROR: syntax error at or near "'sales'"; No query has been executed with that handle
which is invalid either.