program define pswdiff version 2.1 * Do NOT use with: constant, seasonal dummies, polynomial terms * Do not use this version with lag of dependent variable mac def _varlist "req ex min(2)" mac def _if "opt" mac def _in "opt" parse "%_*" parse "%_varlist", parse(" ") mac def _lhs "%_1" mac shift mac def _rhs "%_*" while "%_1" != "" { mac def _c=%_c+1 mac def _new="diff%_c" gen %_new=%_1[_n-1]+%_1[_n+1] replace %_new=%_1 if _n==1 replace %_new=%_1 if _n==_N mac shift } reg %_lhs %_rhs diff* %_if %_in, nocons testparm diff* cap drop diff* end