Hey guys! I'm trying to lag multiple variables (16 in total, e.g. Earnings, Bookvalue, Dividends,...) for each group (permno) depending on their fiscal year-end on SAS 9.4. Here's what I tried for the variable bookvalue: %let _var=bookvalue; Data want; SET have; by permno; If fyr=1 then &_var=lag4(&_var); If fyr=2 then &_var=lag5(&_var); If fyr=3 then &_var=lag6(&_var); If fyr=4 then &_var=lag7(&_var); If fyr=5 then &_var=lag8(&_var); If fyr=6 then &_var=lag9(&_var); If fyr=7 then &_var=lag10(&_var); If fyr=8 then &_var=lag11(&_var); If fyr=9 then &_var=lag12(&_var); If fyr=10 then &_var=lag13(&_var); If fyr=11 then &_var=lag14(&_var); If fyr=12 then &_var=lag15(&_var); RUN; It's working fine, but I don't want to repeat that code for each variable. Is there a way to include the other 15 variables? Thanks a lot!
... View more