之前也写过找rfpendtc变量的方法,今天一看,似乎之前的方法有点复杂,今天写一个简洁点的程序。
/*将所有数据集选出来*/
data aa;
set sashelp.vcolumn;
where libname="RAW" and name like '%DAT_RAW';
run;
/*筛选出来的数据集,变量做成宏变量,方便下一步一一读取*/
proc sql noprint;
select memname,name,count(name) into :dsname separated by ',',:name separated by ',',:n trimmed
from aa;
quit;
%put &dsname. &name. &n.;
%macro dtc;
data dtc;
set %do i = 1 %to &n.;/*利用循环一一读取选出的数据集并合并*/
raw.%scan("&dsname",&i.,",")/*原始数据集*/
(keep=subject %scan("&name",&i.,",")/*选出每个对应数据集中的日期变量*/
rename=(%scan("&name.",&i.,",")=dtc) where=(dtc ne ""))
%end;;
run;
%mend;
%dtc;
找出所有的日期,再排序选择最晚的日期即可。