SAS中文论坛
标题:
求助!
[打印本页]
作者:
shiyiming
时间:
2010-1-31 12:08
标题:
求助!
这是原程序:运行出错!请高手帮忙!
options ps=54 ls=80 nodate;
data method1;title 'griffing method 1';
input f m hybrid rep weight;
drop n nf nm p;
p=5;
array gca(n) g1 g2 g3 g4;
do n=1 to (p-1);
gca=((f=n)-(f=p))+((m=n)-(m=p));
end;
array sca(n) s12 s13 s14 s23 s24;
n=0;
do nf=a to (p-3);
do nm=nf+1 to (p-1);
n=n+1;
sca=(f=nf)*(m=nm)-((f=nf)+(f=nm))*(m=p);
if ((f>=(p-2))&(m>=(p-1))|((f>=(p-1))&(m>=(p-2)))
then do;
sca=-(f=(p-2))*(m=(p-1))+(f>=(p-2))*(m=p)*(f ne nm);
end;
end;
end;
cards;
1 2 1 1 32
1 2 1 2 34
1 2 1 3 29
1 3 2 1 43
1 3 2 2 41
1 3 2 3 42
1 4 3 1 36
1 4 3 2 38
1 4 3 3 34
1 5 4 1 39
1 5 4 2 41
1 5 4 3 40
2 3 5 1 33
2 3 5 2 30
2 3 5 3 29
2 4 6 1 35
2 4 6 2 32
2 4 6 3 33
2 5 7 1 30
2 5 7 2 34
2 5 7 3 34
3 4 8 1 39
3 4 8 2 35
3 4 8 3 36
3 5 9 1 40
3 5 9 2 38
3 5 9 3 36
4 5 10 1 41
4 5 10 2 39
4 5 10 3 38
;
proc glm;
class rep hybrid;
model weight=rep hybrid/ss1;
lsmeans hybrid;
proc glm;
class rep hybrid;
model weight=rep g1 g2 g3 g4 s12 s13 s14 s23 s24;
contrast 'gca'g1 1,g2 1, g3 1,g4 1;
contrast 'sca's12 1,s13 1, s14 1, s23 1, s24 1;
estimate "g1" g1 1; estimate "g2" g2 1;estimate "g3" g3 1;estimate "g4" g4 1;
estimate "g5" g1 -1 g2 -1 g3 -1 g4 -1; estimate 's12's12 1;estimate 's13's13 1;
estimate 's14's14 1;estimate 's23's23 1;estimate 's24's24 1;
estimate "s15" s12 -1 g13 -1 s14 -1;
estimate "s25" s12 -1 g23 -1 s24 -1;
estimate "s34" s12 -1 g13 -1 s14 -1 s23 -1 s24 -1;
estimate "s35" s12 1 s14 1 s24 1;
estimate "s45" s12 1 s13 1 s23 1;
lsmeans hybrid;
quit run;
/*双列杂交试验的配合力分析程序*/
作者:
shiyiming
时间:
2010-2-1 01:24
标题:
Re: 求助!
[code:146xjkwn]data method1;title 'griffing method 1';
input f m hybrid rep weight;
drop n nf nm p;
p=5;
array gca(*) g1 g2 g3 g4;
do n=1 to (p-1);
gca[n] = ((f=n)-(f=p))+((m=n)-(m=p));
end;
array sca(*) s12 s13 s14 s23 s24;
n=0;
do nf=1 to (p-3);
do nm=nf+1 to (p-1);
n = n+1;
sca[n] = (f=nf)*(m=nm)-((f=nf)+(f=nm))*(m=p);
if ( (f>=(p-2)) & (m>=(p-1)) | ( (f>=(p-1)) & (m>=(p-2)) )) then do;
sca[n] = -(f=(p-2))*(m=(p-1))+(f>=(p-2))*(m=p)*(f ne nm);
end;
end;
end;
cards;
1 2 1 1 32
1 2 1 2 34
1 2 1 3 29
1 3 2 1 43
1 3 2 2 41
1 3 2 3 42
1 4 3 1 36
1 4 3 2 38
1 4 3 3 34
1 5 4 1 39
1 5 4 2 41
1 5 4 3 40
2 3 5 1 33
2 3 5 2 30
2 3 5 3 29
2 4 6 1 35
2 4 6 2 32
2 4 6 3 33
2 5 7 1 30
2 5 7 2 34
2 5 7 3 34
3 4 8 1 39
3 4 8 2 35
3 4 8 3 36
3 5 9 1 40
3 5 9 2 38
3 5 9 3 36
4 5 10 1 41
4 5 10 2 39
4 5 10 3 38
;
proc glm;
class rep hybrid;
model weight=rep hybrid/ss1;
lsmeans hybrid;
proc glm;
class rep hybrid;
model weight=rep g1 g2 g3 g4 s12 s13 s14 s23 s24;
contrast 'gca' g1 1,g2 1, g3 1,g4 1;
contrast 'sca' s12 1,s13 1, s14 1, s23 1, s24 1;
estimate "g1" g1 1; estimate "g2" g2 1;estimate "g3" g3 1;estimate "g4" g4 1;
estimate "g5" g1 -1 g2 -1 g3 -1 g4 -1; estimate 's12' s12 1;estimate 's13' s13 1;
estimate 's14' s14 1;estimate 's23' s23 1;estimate 's24' s24 1;
estimate "s15" s12 -1 s13 -1 s14 -1;
estimate "s25" s12 -1 s23 -1 s24 -1;
estimate "s34" s12 -1 s13 -1 s14 -1 s23 -1 s24 -1;
estimate "s35" s12 1 s14 1 s24 1;
estimate "s45" s12 1 s13 1 s23 1;
quit;[/code:146xjkwn]
Basically, original code doesn’t work in 1. ARRAY parameter in data step 2. Undefined variables in GLM procedure.
I don’t know if the code works in its statistical logic. But it functions apparently in the program itself.
JingJu
作者:
shiyiming
时间:
2010-2-2 08:28
标题:
Re: 求助!
谢谢指导!
欢迎光临 SAS中文论坛 (https://mysas.net/forum/)
Powered by Discuz! X3.2