1

我是 SAS 的新手,并且在 sql 中有最新的代码,我已经被困了一段时间才能在 SAS 平台中转换它。我也尝试在 SAS 中使用 do..while 循环,但它没有用。

for c in (select * from risk.mv_closed_deals d) loop    
  for DatesToInsert in (select distinct(T1.ACTUAL_DATE) as ACTUAL_DATE from VINTAGE_MTD T1 where T1.Actual_Date>c.closed_date) loop
     insert into VINTAGE_MTD (dealdate, actual_date, deal_month, mob, dealno, balance, loanamount, overduedays, status, server)
     values (c.issue_date, DatesToInsert.Actual_Date, to_char(c.issue_date,'yyyy/mm'),
     (to_char(DatesToInsert.actual_date,'yyyy')-to_char(c.issue_date,'yyyy'))*12 + to_char(DatesToInsert.actual_date,'mm') - to_char(c.issue_date,'mm') - 1,
     c.dealno, 0, c.loanamount, 0, 0, 'B2');
  end loop; 
end loop;
4

1 回答 1

1

我会尝试这样的事情:

proc sql;

create table vintage_mdt_new as
select c.issue_date as dealdate
      ,DatesToInsert.Actual_Date as actual_date
      ,put(c.issue_date, yymms.) as deal_month
      ,intck('month', DatesToInsert.actual_date, c.issue_date) as mob
      ,c.dealno as dealno
      ,0 as balance
      ,c.loanamount as loanamount
      ,0 as overduedays
      ,0 as status
      ,'B2' as server
from (select * from risk.mv_closed_deals) as c
     ,(select distinct(T1.ACTUAL_DATE) as ACTUAL_DATE 
       from VINTAGE_MTD T1) as DatesToInsert
where DatesToInsert.Actual_Date > c.closed_date;

quit;

proc append base=VINTAGE_MTD data=vintage_mdt_new;

没试过所以不知道能不能用。

于 2012-11-16T07:25:34.687 回答