Hi Statalist users,

I need advice on the following problem.

Suppose I have two macros

local b "b1 b2"
local var "var1 var2"

What would be an elegant way to create macro that contains a string "b1*var1+b2*var2"?

Just to place it into context -- I want to compute fitted value that is based on a regression prediction, but not for all Xs. Something along these lines (but it needs to be general solution for any subset of independent variables):

reg y X1 X2 X3

gen yhat=_b[X1]*X1+_b[X2]*X2



Thanks, Oleksandr