proc IML;
r={1.00 0.30,
0.30 1.00};
s={1 0,
0 1};
E=s*r*s;
u={0,0};
do i=1 to 100;
z1=rannor(0);
z2=rannor(0);
c=root(E);
xi=c`*(z1//z2)+u;
m=m//xi`;
end;
create example var{x y};
append from m;
proc print;
run;
proc means;
run;
proc freq;
run;
data freq;
set example;
run;
data example1; /*新建一个数据集*/
set example; /*从example中读取数据*/
if x<=-1 then x1=1;
else if x>-1 and x<=1 then x1=2;
else x1=3;
if y<=-1 then y1=1;
else if y>-1 and y<=1 then y1=2;
else y1=3;
output;
PROC PRINT;
RUN;
proc means;
run;
proc freq;
run;
proc corr spearman;
var x1 y1;
run;
/*3、求出r*c列联表中的各个数据*/
data example2; /*新建一个数据集*/
set example1; /*从example1中读取数据*/
if x1=1 and y1=1 then r11=1;
else if x1=1 and y1=2 then r12=1;
else if x1=1 and y1=3 then r13=1;
else if x1=2 and y1=1 then r21=1;
else if x1=2 and y1=2 then r22=1;
else if x1=2 and y1=3 then r23=1;
else if x1=3 and y1=1 then r31=1;
else if x1=3 and y1=2 then r32=1;
else if x1=3 and y1=3 then r33=1;
output;
PROC PRINT;
RUN;
proc means;
run;
proc freq;
run;
/*对r*c表中各个频数求和*/
proc means data=example2 n;
var r11 r12 r13 r21 r22 r23 r31 r32 r33;
run;
用这段程序求出7个变量值,我希望这个程序可以循环产生2000组值,便于进一步分析。有什么方法可以直接把2000组数据存储到一个数据集里面吗?困扰许久,求教各位大侠,不甚感激。
|