lilinzhong
想了两天后终于实现了,采用纵向数据结构,即一个变量名下为一个序列.数个变量(序列)用数组进行对一个观测进行计数:
data s;
input (x1-x4) ($);
array alphabet[26] $ ('A' 'B' 'C' 'D' 'E' 'F' 'G' 'H' 'I' 'J' 'K' 'L' 'M' 'N' 'O' 'P'
'Q' 'R' 'S' 'T' 'U' 'V' 'W' 'X' 'Y' 'Z');/*assign the alphabet to array for it is difficult to calculate count with letters*/
array y[4] $ x1-x4; /* assign all fields or variables to array y.*/
count=0;
do k=1 to 26;/*calculate the count of mutation*/
do i=1 to 4;
if y=alphabet[k] then do;
count+1;
goto FLAG;
end;
end; FLAG:;
end;
cards;
Q Q Q Q
W W W Q
A A A Q
Q Q Z A
A A A A
;
run;
proc gplot data=dna_compress;
plot count*site/vaxis=1 2 3 4 haxis=0 to 200 by 10;
symbol i=needle v=plus c=red cv=blue;
where 0<=site<=200; /*define the scope of the site*/
run;
quit;