我想只在临时数据集的'count'列中的任何值大于或等于10时创建新的数据集。
Name Fruit Count Name Fruit Count
Jon Apple 2 Tim Apple 4
Jon Pear 1 Tim Pear 7
Jon Kiwi 9 Tim Kiwi 10
因此,读取第一个表将忽略它,读取第二个表将创建一个名为“Tim”的新数据集。我正在使用PROC MEANS来计算某些值并写入临时数据集。从那里我想读一读,如果满足条件,则创建新的数据集。
答案 0 :(得分:0)
data temp;
input name $ fruit $ count;
datalines;
Jon Apple 2
Jon Pear 1
Jon Kiwi 9
Tim Apple 4
Tim Pear 7
Tim Kiwi 10
;
run;
/*
2 options:
all obs for Tim
*/
data _NULL_;
set temp;
file "MyPath\NewDataset.sas";
if count>=10 then do;
put "data " name ";";
put " set temp(where=(name='" name +(-1) "'));";
put "run;";
end;
run;
/* only the obs with count>=10 */
data _NULL_;
set temp;
file "MyPath\NewDataset.sas";
if count>=10 then do;
put "data " name ";";
put " set temp;";
put " if _N_=" _N_ ";";
put "run;";
end;
run;
%include "MyPath\NewDataset.sas";