今天我看到这么两个程序:
*****************第一个******************;
data _null_;
/* program to compute probabilities for the 2 by 2 table. */
window two color=red rows=10 irow=10 group=inter
#1 @32 '2 by 2 TABLE' color = black
#2 @12 '+--------------------------------------------+' color = black
#3 @12 '|' color=black +1 n1 @35 '|' color=black
+1 n2 @57 '|' color=black +2 m1 color=cyan
#4 @12 '+--------------------------------------------+' color = black
#5 @12 '|' color=black +1 n3 @35 '|' color=black
+1 n4 @57 '|' color=black +2 m2 color=cyan
#6 @12 '+--------------------------------------------+' color = black
#7 @13 p1 color=yellow @37 p2 color = yellow @60 n color=blue
#8 @2 'Enter Odds Ratio'
+1 or 4.2 @25 'Prob(n11<=' +1 t1 4. ')=' prob 6.4;
do while(upcase(_cmd_) ne 'STOP');
display two ;
link compute;
end;
stop;
compute:
m1 = n1 + n2; m2 = n3+n4; p1=n1+n3; p2=n2+n4;
n=m1+m2; t1 = n1;
prob=probhypr(n,m1,p1,n1,or);
return;
run;
********************第二个***********************;
proc iml;
/*---worm---*/
/* head @ body = food X empty . barrier / */
start worminit;
window w rows=14 columns=22 icolumn=20;
rowmove={0 0 1 -1};
colmove={1 -1 0 0};
nr=10; nc=20;
a = repeat("X",nr,nc); /* the game field */
a[3,8:12]="/";
a[7,8:12]="/";
r = { 5 5 5 5 }; /* initial row position */
c = { 8 9 10 11}; /* initial col position */
loc=(r-1)*nc+c;
a[loc]={"@" "=" "=" "="}; /* place worm in field */
* a[3,7:13]="B";
* a[7,7:13]="B";
ok = 1;
finish;
start wormmove;
/*-clear old tail-*/
a[r[4],c[4]]='.';
a[r[1],c[1]]="=";
r=r[{4 1 2 3}];
c=c[{4 1 2 3}];
/*-try new direction-*/
iii=0;
tryagain: iii=iii+1; if iii>20 then do; ok=0; stop; end;
move=int(uniform(0)#4)+1;
r1 = r[2]+rowmove[move];
c1 = c[2]+colmove[move];
if r1<1
| r1>nr then goto tryagain;
if c1<1
| c1>nc then goto tryagain;
if a[r1,c1]^="X" then
if a[r1,c1]^='.' then goto tryagain;
freq=256; if a[r1,c1]="X" then freq=312;
/*--make new move--*/
r[1] = r1;
c[1] = c1;
a[r1,c1]="@";
finish;
freq=256;
start wormshow;
showa = cshape(a,nr,1,nc);
display w ( / showa color="YELLOW" protect=yes ) repeat;
call sound(freq,.05);
finish;
run worminit;
start;
do i=1 to 100; run wormshow; run wormmove; end;
finish;
/* You can ask the worm to "run" as many times as you like. */
/* The run; below will get him started. */
run;
************************************END******************************************;
然后,我突发奇想:不知道有哪位SAS高手有如此雅兴:可以用SAS程序编写出sudoku(9x9和16x16)游戏?要求,这个程序里至少要由两部分:
1。生成器(generator)
a。生成器里要有对称的(symetrical)和不对称的(non-symetrical)两种生成方法。
b。还要有四个水平的选择:容易(easy),中度难(medium),难(hard),专家级(expert)。
2。检测或解答器(solver)
a。选择性的即时提示对错
b。一键自动打印出最后答案!
3。不知道,可不可以再加上计时器显示?