是否可以将具有max函数的子选择转换为SAS数据步?

问题描述 投票:0回答:1

是否可以将下面的代码从proc sql转换为sas datastep?

proc sql;
create table CAL_CHECK as
select t1.DT_REP 
     , t1.BANK_FLAG
     , (select MAX(t2.DT_REP) as LAST_BD_BANK_FLAG from CZ_LOOK.CZ_CALENDAR t2 where t2.DT_REP < t1.DT_REP and t2.BANK_FLAG='Y') as LAST_BD 
from CZ_LOOK.CZ_CALENDAR t1
where dt_rep between &first_day. and &last_day.;
quit;

感谢您的回复

示例:

DT_REP      LAST_BD
01.04.2020  31.03.2020
02.04.2020  01.04.2020
03.04.2020  02.04.2020
04.04.2020  03.04.2020
05.04.2020  03.04.2020
06.04.2020  03.04.2020
07.04.2020  06.04.2020
08.04.2020  07.04.2020

1.4。是星期三,所以最后一个银行工作日是31.3,5.4。是星期日,所以最后一个银行营业日是3.4,6.4。是星期一,因此最后一个银行营业日为3.4。到

sas aggregate proc datastep sql-subselect
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.