- %MACRO TRIANGLE(LINENo);
- %do i=1 %to &lineno;
- %let str=;
- %do j=1 %to &i;
- %if &j=1 or &j=&i %then
- %let x&i.y&j=1;
- %else
- %do;
- %let upline=%eval(&i-1);
- %let up1=%eval(&j-1);
- %let x&i.y&j=%eval(&&x&upline.y&up1+&&x&upline.y&j);
- %end;
- %let str=&str%qsysfunc(repeat(%str( ),%eval(5-%length(&&x&i.y&j))))&&x&i.y&j;
- %end;
- %let str=%qsysfunc(repeat(%str( ),%eval((&lineNo-&j+1)*3)))%str(&str);
- %put %str(&str);
- %end;
- %MEND;
- %TRIANGLE(15);
纯宏程序打印完全数、完美数(Perfect number)
- %macro divisor(Num,print=0);
- %local allDivisor ;
- %do Divisor=1 %to %eval(&Num/2+1);
- %if %sysfunc(mod(&Num,&divisor))=0 %then %let allDivisor=&alldivisor+&divisor;
- %end;
- %if &print %then %put &allDivisor;
- %eval(0&allDivisor)
- %mend;
- %macro complete(N);
- %local one;
- %do one=1 %to &n;
- %if &one=%divisor(&one) %then %put one=&one %divisor(&one,print=1);
- %end;
- %mend;
- %complete(1000);
纯宏程序打印相亲数(Amicable)
- %macro divisor(Num,print=0);
- %local allDivisor ;
- %do Divisor=1 %to %eval(&Num/2+1);
- %if %sysfunc(mod(&Num,&divisor))=0 %then %let allDivisor=&alldivisor+&divisor;
- %end;
- %if &print %then %put &allDivisor;
- %eval(0&allDivisor)
- %mend;
- %macro love(N);
- %local one anotherone;
- %do one=1 %to &n;
- %let anotherOne=%divisor(&one);
- %if %divisor(&anotherOne)=&one and &one ne &anotherOne %then %put one=&one %divisor(&one,print=1) anotherone=&anotherone %divisor(&Anotherone,print=1);
- %end;
- %mend;
- data _null_;
- call symput('ahuigefromtime',put(time(),time8.));
- run;
- %love(1500);
- data _null_;
- diff=time()-input("&ahuigefromtime",time8.);
- put '################ time used :' diff time8.;
- run;
》》》》》》》》》》》》》》》》》》》》》》》》
ahuige



雷达卡




京公网安备 11010802022788号







