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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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