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

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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
  • 486 views
  • 0 likes
  • 2 in conversation