标题: SAS也能编出乐曲程序 [打印本页] 作者: shiyiming 时间: 2003-9-12 13:56 标题: SAS也能编出乐曲程序 [code:13e31]data holidays;
retain fmtname '@$holiday';
length data $3;
ratio = 1.05946309436;
str1 ='A A#B C C#D D#E F F#G G#';
str2='A BbCbB#DbD EbFbE#GbG Ab';
o = 1;
do i = 0 to 87;
p = 55 * ratio**i;
data = compress(substr(str1,mod(i,12)*2+1,2)||o);
output;
if data^=compress(substr(str2,mod(i,12)*2+1,2)||o) then do;
data = compress(substr(str2,mod(i,12)*2+1,2)||o);
output;
end;
if mod(i,12)=2 then o=o+1;
end;
rename data=start p=label;
keep fmtname data p;
run;