Thanks to Everyone who replied. As usual, I'm immensely grateful for the intelligent responses I received. My largest concern was that for each record we were creating 15 lagged variables whether or not they were needed for the calculations--the number of needed lagged variables is based on the loan_count--if loan_count=2 then we need 2 lagged variables and only if it is more than 6 do we need all 15. As a short-term fix until I can further investigate the temporary array approach I'm using this code that lags only the fields needed for the calculation. if loan_count = 2 then do; ** here create only the lagged variables we need. ; dpd_lag1 = lag(dpd); pay_lag1 = lag(payment_amount); max_dpd = max(dpd,dpd_lag1); max_dpd_2 = dpd_lag1; if dq_monthly_payment > 0 then do; CHRVA421 = (100 * payment) / dq_monthly_payment; CHRVA421P = (100 * sum(payment_amount,pay_lag1)) / (dq_monthly_payment * 2); end; end; else if loan_count = 4 then do; dp_lag1 = lag(dpd); pay_lag1 = lag(payment_amount); prin_lag1 = lag(payment); dpd_lag2 = lag2(dpd); pay_lag2 = lag2(payment_amount); prin_lag2 = lag2(payment); dpd_lag3 = lag3(dpd); pay_lag3 = lag3(payment_amount); max_dpd = max(dpd,dpd_lag1,dpd_lag2,dpd_lag3); max_dpd_2 = max(dpd_lag1,dpd_lag2,dpd_lag3); if dq_monthly_payment > 0 then do; CHRVA421 = (100 * sum(payment,prin_lag1,prin_lag2)) / (dq_monthly_payment * 3); CHRVA421P = (100 * sum(payment_amount,pay_lag1,pay_lag2,pay_lag3))/(dq_monthly_payment * 4); end; end; else if loan_count > 6 then do; dpd_lag1 = lag(dpd); pay_lag1 = lag(payment_amount); prin_lag1 = lag(payment); dpd_lag2 = lag2(dpd); pay_lag2 = lag2(payment_amount); prin_lag2 = lag2(payment); dpd_lag3 = lag3(dpd); pay_lag3 = lag3(payment_amount); prin_lag3 = lag3(payment); dpd_lag4 = lag4(dpd); pay_lag4 = lag4(payment_amount); prin_lag4 = lag4(payment); dpd_lag5 = lag5(dpd); pay_lag5 = lag5(payment_amount); prin_lag5 = lag5(payment); max_dpd = max(dpd,dpd_lag1,dpd_lag2,dpd_lag3,dpd_lag4,dpd_lag5); max_dpd_2 = max(dpd_lag1,dpd_lag2,dpd_lag3,dpd_lag4,dpd_lag5); if dq_monthly_payment > 0 then do; CHRVA421 = (100 * sum(payment,prin_lag1,prin_lag2,prin_lag3,prin_lag4,prin_lag5))/(dq_monthly_payment*6); CHRVA421P = (100 * sum(payment_amount,pay_lag1,pay_lag2,pay_lag3,pay_lag4,pay_lag5))/(dq_monthly_payment*6); end; end;
... View more