2010-11-04 119 views
-2

在SPSS中如何編程公式的最佳方法是:l(x)= l(x-1)-d(x-1)其中l(x)是x年齡段處於危險中的總人數; d(x)是x年齡組的總死亡人數。所以,d(x-1)是x-1年齡組的總死亡率。謝謝如何在SPSS中編程l(x)= l(x-1)-d(x-1)?

+0

添加一些樣本數據將使問題更容易(可能)理解 – 2016-05-13 14:07:30

回答

1

我不確定我是否完全理解了您的問題,但您可能能夠利用SPSS中的LAG功能。

看看下面的語法來得到一個想法:

*--------------------------------------------------------------------------------------------------. 
* Lets create some fake data. 
*--------------------------------------------------------------------------------------------------. 
DATA LIST LIST (",")/id risk death. 
BEGIN DATA 
1, 274, 123 
1, 123, 34 
1, 1235, 23 
2, 3456, 231 
2, 1897, 12 
END DATA. 

*--------------------------------------------------------------------------------------------------. 
* Create a basic lag to get the previous record's values. 
*--------------------------------------------------------------------------------------------------. 
COMPUTE risk.lag1 = LAG(risk, 1). 
COMPUTE death.lag1 = LAG(death, 1). 

*--------------------------------------------------------------------------------------------------. 
* Create a lag if group dependent -- assumes your cases are in the order you want 
* Only executes if the previous records value of ID is the same as the current record. 
*--------------------------------------------------------------------------------------------------. 
IF (id = LAG(id,1)) risk.lag2 = lag(risk,1). 
IF (id=LAG(id,1)) death.lag2 = lag(death,1). 
EXECUTE. 

*--------------------------------------------------------------------------------------------------. 
* ....And the data..... 
*--------------------------------------------------------------------------------------------------. 
LIST CASES. 

爲您提供以下數據計算....

 id  risk death risk.lag1 death.lag1 risk.lag2 death.lag2 

     1  274  123   .   .   .   . 
     1  123  34  274  123  274  123 
     1  1235  23  123  34  123  34 
     2  3456  231  1235  23   .   . 
     2  1897  12  3456  231  3456  231 


Number of cases read: 5 Number of cases listed: 5 
相關問題