sas - LAG function doesn't complete -


i constructing life table. data looks this:

age    npx        ================= 0-1    0.996 1-4    0.9955 5-9    0.9966 

i want construct new variable lx. value of lx age="0-1" 100,000. value "1-4" lx * npx previous record.

here's code:

 if age = "0-1" lx = 100000;  lag_lx  = lag1 (lx);  lag_npx = lag1 (npx);   lx = lag_lx * lag_npx; 

what happens program stops calculating lx after 2nd record; record 3 on, lx has . (missing)

i go down ifn route here doesn't screw think lagged value , makes code simple (have read of this paper). need retain statement stated @alex a.

data have;     input age $ npx;     datalines; 0-1    0.996 1-4    0.9955 5-9    0.9966 ;  data want; set have; retain lx; lx = ifn(age='0-1',100000,lx*lag(npx)); run; 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -