我正在尝试将数据集拆分为多个数据集,然后将它们导出到一个包含多个选项卡的Excel文件中。这是我试过的:
%let term1=2010;
%let new1=newa;
%let new2=newb;
%let dim_new=2;
%let school1=schoola;
%let school2=schoolb;
%let dim_school=2;
%macro split;
%do n=1 %to &dim_new;
%do m=1 %to &dim_school;
data retention&term1._new&n._school&m;
set retention&term1;
if new_student="new&n" and acad_group="school&m" then output;
run;
%end;
%end;
%mend;
%macro exportresult;
%do n=1 %to &dim_new;
%do m=1 %to &dim_school;
libname datadir "B:\report";
proc export data=retention&term1._new&n._school&m
outfile="B:\report\retention&term1._new&n"
dbms=xlsx replace;
sheet="school&m";
run;
%end;
%end;
%mend;
%split;
%exportresult;
我在每个数据集中都没有观察到。导出的Excel只有最后一所学校。我认为它可以有两个标签。
任何人都可以帮我解释原因吗?
谢谢!