BookmarkSubscribeRSS Feed
Q1983
Lapis Lazuli | Level 10
proc sql noprint; 
connect  to DB2 (&cpplogin);
create table t_escrow as select * from connection to db2
   ( SELECT distinct *
     FROM DX.T_escrow_1
	  WHERE tran_date >= '2019-01-01'
	  and loan_num in ('2211','3123','908766','9876') /*need to replace this line with
	  a new select statement and new passthrough connection.*/
		and UPDATE_CD IN ('A','C')   
  	  order by ln_no,tran_date desc
		 	    WITH UR  
   );
     disconnect from db2;
quit;


proc sql;
        connect to sqlsvr (&dlogin_new.);
        CREATE TABLE loan_lookup AS 
        (       SELECT * FROM connection to sqlsvr 
               (       
                       
			   	select lnbr
                       FROM D_Tran.dbo.DT_DBBT_Lookup
               )
        )
        ;
        disconnect from sqlsvr;
        run;
quit;

I need to integrate loan_lookup into the t_escrow table.  It will be filtered based on the loan_lookup query however notice the connections are slightly different.  Would I need to run the queries separately then combine them (not preferred) or is there a way to handle this in the same iteration despite two different connection strings

1 REPLY 1
Tom
Super User Tom
Super User

I don't understand what the question is.  You can definitely be connected to multiple external databases at the same time.

proc sql;
  connect to a;
  connect to b;
  create table c as
   select * 
   from (select * from connection to a (select * from table_in_a)) a
   left join (select * from connection to b (select * from table_in_b)) b
  on a.id = b.id
  ;
quit;

But I have a feeling you are trying to ask a different question.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 1 reply
  • 449 views
  • 0 likes
  • 2 in conversation