2017-02-15 82 views
-1

Please see attached file如何总结SAS中当前行的前一行值?

我需要一个求和列,但是,保留和滞后突击队员都是低效的。

+2

欢迎来到SO。请输入问题而不是链接图片,也请显示您迄今为止所做的工作。 –

+0

显示你用RETAIN或LAG试过的东西 - 两者都可以在理论上工作(我认为保留效果更好)。 – Joe

回答

0

有很多方法。您可以使用proc sqlproc表示。我写了下面的方法:

data begin; 
    length person $3 sallary 5; 
    input person sallary; 
    datalines; 
    a 200 
    a 300 
    b 800 
    c 400 
    c 500 
    c 600 
    ; 
run; 

proc means data=begin noprint; 
    by person; /*Handle each person as distinct subset*/ 
    output out=Sal_by_person(drop= _type_ _freq_) 
    sum(sallary)=Total_sallary /*What we calculate and what we call them.*/ 
    ; 
run; 
相关问题