BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jim_toby
Quartz | Level 8

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!

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star
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;

View solution in original post

2 REPLIES 2
r_behata
Barite | Level 11

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.

SASKiwi
PROC Star
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;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 4016 views
  • 0 likes
  • 3 in conversation