Skip to content Skip to sidebar Skip to footer

Combine Different Sql Into One Table Using Sas

I would like to know how to combine different SQL queries into one table. The format should be customer_no|TOTAL_DIFF_LASTPAYMENT_OPENED_dt|utilization trend| count_enquiry_rec

Solution 1:

Are you trying to join the result on customer_no?

   proc sql;
    create table want as
    select t1.customer_no
          ,avg(t1.TOTAL_DIFF_LASTPAYMENT_OPENED_dt) as proc1
          ,sum(t1.cur_balance_amt /t1.creditlimit) / avg(t1.cur_balance_amt/(t1.creditlimit+t1.creditlimit)) as proc2
          ,sum(t2.enq_amt) as proc3
          ,sum(t3.cur_balance_amt/ t3.creditlimit) as proc4
    from account_30_sort t1
        ,enquiry_30(where=(dt_opened - enquiry_dt <= 365)) t2
        ,account_30 t3
    where t1.customer_no=t2.customer_no
      and t2.customer_no=t3.customer_no
    group by t1.customer_no
    ;
    quit;

Post a Comment for "Combine Different Sql Into One Table Using Sas"