SAS中文论坛

标题: 求高手解答:2到小编程 [打印本页]

作者: shiyiming    时间: 2011-6-6 10:31
标题: 求高手解答:2到小编程
程序1: 求1到100的和



程序2:
编程:输出下面数组中最大的值:
88 95 80 90 99 100 89 92 89 79
77 68 98 100 88 89 84 78 88 97
作者: shiyiming    时间: 2011-6-6 11:18
标题: Re: 求高手解答:2到小编程
[code:2hkz529s]%macro sum(x=,y=);
        %put from x to y equals %eval((&x+&y)*(&y-&x+1)/2);
%mend sum;
%sum(x=1,y=100);

data tmp;
input a @@;
cards;
88 95 80 90 99 100 89 92 89 79
77 68 98 100 88 89 84 78 88 97
;
run;
proc sort data=tmp;
        by a;
run;
data _null_;
set tmp end=last;
if last then put 'The max number is ' a;
run;[/code:2hkz529s]
作者: shiyiming    时间: 2011-6-6 14:22
标题: Re: 求高手解答:2到小编程
data a;
   do i=1 to 100 by 1;
   output;end;
run;
data tmp;
input a @@;
cards;
88 95 80 90 99 100 89 92 89 79
77 68 98 100 88 89 84 78 88 97
;
run;

proc means data=a sum;
   var i;
run;
proc means data=tmp max ;
  var a;
run;
作者: shiyiming    时间: 2011-6-6 20:33
标题: Re: 求高手解答:2到小编程
data tmp;
retain maxa 0;

input a @@;
if a> maxa then maxa=a;

cards;
88 95 80 90 99 100 89 92 89 79
77 68 98 100 88 89 84 78 88 97
;
run;
data want;
set tmp end=last;
keep maxa;
if last;
run;


data a;
do i=1 to 100;
tot=sum(tot,i);
end;
output;
keep tot;
run;
作者: shiyiming    时间: 2011-6-23 14:53
标题: Re: 求高手解答:2到小编程
data a;
       do i=1 to 100;
            sum+i;
       end;
       drop i;
run;       

data tmp;
input a @@;
cards;
88 95 80 90 99 100 89 92 89 79
77 68 98 100 88 89 84 78 88 97
;
run;

proc sql noprint;
      select max(a) into:max from tmp;
quit;
%put &max;




欢迎光临 SAS中文论坛 (http://www.mysas.net/forum/) Powered by Discuz! X3.2