输出多个数据集

Output multiple dataset

我想从一个数据集输出到多个数据集,所以我想编写这样的代码

data SmallDatasetName_1 - SmallDatasetName_100;
set BigDatasetName;
/*here some code*/
run;

所以,如果我尝试这样做,我会收到错误消息。我可以解决它(通过使用 select 进入)。但是它是否存在 "simple" 语法,类似于

data BigDatasetName;
set SmallDatasetName_1 - SmallDatasetName_100;
/*here some code*/
run;

?

据我所知,您不能在 data 语句中使用数据集列表。您可以使用宏来生成代码。先定义宏:

options mprint;
%macro split;
  data 
    %do I = 1 %to 5;
      SmallDatasetName_&I
    %end;;
    set BigDatasetName;
    %do I = 1 %to 5;
      if **your conditions here** then output SmallDatasetName_&I;
    %end;;
  run;
%mend split;

调用宏使用:

%split;

这会生成如下所示的 sas 代码:

data 
  SmallDatasetName_1
  SmallDatasetName_2
  SmallDatasetName_3
  SmallDatasetName_4
  SmallDatasetName_5
  ;
  set BigDatasetName;
  if **your conditions here** then output SmallDatasetName_1;
  if **your conditions here** then output SmallDatasetName_2;
  if **your conditions here** then output SmallDatasetName_3;
  if **your conditions here** then output SmallDatasetName_4;
  if **your conditions here** then output SmallDatasetName_5;
run;