webuse grunfeld,clear reshape wide invest mvalue kstock,i(year) j(company) forv i=1/4 { local eqns "`eqns' (invest`i' mvalue`i' kstock`i')" } sureg `eqns' mat cns = J(6,13,0) local nc 1 forv i=1/2 { forv j=0(3)6 { mat cns[`nc',`i'+`j'] = 1 mat cns[`nc',`i'+`j'+3] = -1 local ++nc } } mat list cns mat_put_rr cns test mat makeCns cns mat dispCns sureg `eqns', c(1/6)