悬赏 1 个论坛币 未解决
求解SAS程序。因为论坛币没有多少,只是聊表心意,非常感谢!
要实现目标:利用循环求多个数据样本的标准差。
数据集时间范围[-230,230]
循环t=-100 to 100;
计算[-230,t] 和 [t,230]两段数据的标准差。
自己写的程序:
请教了一位老师,说是程序可以直接这样写,可是实现不了,不知道哪里出了问题,请高手指教?
data cd1;
do i=-100 to 100;
data temp tempe;
set cd1;
if date<&i then output temp;
else output tempe;
run;
proc means std data=temp;
var spread;
output out=stdv stddev=std;
run;
proc means std data=tempe;
var spread;
output out=std stddev=std;
run;
end;
run;
使用宏
*宏程序*/
%macro data;
data temp tempe;
set cd1;
if date<&i then output temp;
else output tempe;
run;
%mend data;
%macro a;
proc means std data=temp;
var spread;
output out=std stddev=std;
run;
%mend a;
data cd1;
do i=-100 to 100;
%data;
%a;
end;
run;