SAS中文论坛

标题: 新手问个相当简单的问题 [打印本页]

作者: shiyiming    时间: 2010-8-6 08:39
标题: 新手问个相当简单的问题
有变量x1-x99,
要定义新的变量y1=(x1+x2+x3)/3,y2=(x2+x3+x4)/3,以此类推,这个怎么实现?
作者: shiyiming    时间: 2010-8-6 09:11
标题: Re: 新手问个相当简单的问题
y98,y99的公式是什么?
作者: shiyiming    时间: 2010-8-6 09:12
标题: Re: 新手问个相当简单的问题
不好意思,忘说了,最后两个不计
作者: shiyiming    时间: 2010-8-6 09:24
标题: Re: 新手问个相当简单的问题
[code:2qurng93]data raw(drop=i);
        array x{99};
        do i=1 to 99;
                x(i)=ceil(10*ranuni(1223456));
        end;
run;
data out(keep=y:);
        set raw;
        array x{*} x1-x99;
        array y{97};
        do i=1 to dim(y);
                y(i)=mean(x(i),x(i+1),x(i+2));
        end;
run;[/code:2qurng93]
作者: shiyiming    时间: 2010-8-6 09:50
标题: Re: 新手问个相当简单的问题
3QU
作者: shiyiming    时间: 2010-8-6 21:03
标题: Re: 新手问个相当简单的问题
to hopewell
小哥:他要除以3,你为什么给mean呢?
作者: shiyiming    时间: 2010-8-6 23:25
标题: Re: 新手问个相当简单的问题
?????
[quote:2yjondhb]小哥:他要除以3,你为什么给mean呢?[/quote:2yjondhb]
作者: shiyiming    时间: 2010-8-7 00:43
标题: Re: 新手问个相当简单的问题
when missing value exist, the mean will create  a no missing value if there are at least one no missing value present and logically the  denominator will not the 3.




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