我希望从一个数据集输出到多个数据集,所以我想编写类似这样的代码
data SmallDatasetName_1 - SmallDatasetName_100;
set BigDatasetName;
/*here some code*/
run;
所以,如果我试试这个,我会收到一个错误。我可以解决它(使用select into)。但它是否存在“简单”的语法,类似于
data BigDatasetName;
set SmallDatasetName_1 - SmallDatasetName_100;
/*here some code*/
run;
答案 0 :(得分:2)
据我所知,您无法在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;