I have an SQL pass through written in SAS that basically returns a limit of 100 records from a table stored in Netezza. I would like to also return 100 records from another table in Netezza without having to re-connect. Here's what I got:
proc sql;
connect to odbc as odbcCon
(noprompt='Driver={NetezzaSQL}; server=xxxxxx; port=xxxxx; database=xxx; username=xxxx; password=xxxxx;');
select * from connection to odbcCon
(SELECT *
FROM SCHEMA.table1
LIMIT 100;);
quit;How can I select from table2 within the same connection? I tried doing this:
proc sql;
connect to odbc as odbcCon
(noprompt='Driver={NetezzaSQL}; server=xxxxxx; port=xxxxx; database=xxx; username=xxxx; password=xxxxx;');
select * from connection to odbcCon
(SELECT *
FROM SCHEMA.table1
LIMIT 100;),
(SELECT *
FROM SCHEMA.table2
LIMIT 100;);
quit;But I get a syntax error. Any help would be great!
proc sql;
connect to odbc as odbcCon
(noprompt='Driver={NetezzaSQL}; server=xxxxxx; port=xxxxx; database=xxx; username=xxxx; password=xxxxx;');
select * from connection to odbcCon
(SELECT *
FROM SCHEMA.table1
LIMIT 100;);
select * from connection to odbcCon
(SELECT *
FROM SCHEMA.table2
LIMIT 100;);
quit;
First , I reckon your second query syntax would not work in Netezza let alone sas. If your tables have anything in common try joining them (inner, outer etc ) or use the union operator.
proc sql;
connect to odbc as odbcCon
(noprompt='Driver={NetezzaSQL}; server=xxxxxx; port=xxxxx; database=xxx; username=xxxx; password=xxxxx;');
select * from connection to odbcCon
(SELECT *
FROM SCHEMA.table1
LIMIT 100;);
select * from connection to odbcCon
(SELECT *
FROM SCHEMA.table2
LIMIT 100;);
quit;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.