Hi Stata users,

I have some problems with the calculation of matrix with database. For example, I have a database with

So my question is (1) how to write the code to calculate the above formula, and (2) in a general way, if the number of my matrix values is not exact the same as the number of variables in the database, for example, I have x1-x100 variables, but I have the matrix with values beta1-beta105, x variables could be partly matched to matrix according to their names, how shall I write the code?

Thank you very much.

I have some problems with the calculation of matrix with database. For example, I have a database with

**100 variables (x1-x100) and 200 observations**. And I have also**a matrix with values beta1-beta100**, I need to do this calculation:__for each observation__, I need to generate a__new variable__which is:**x1*beta1+x2*beta2+x3*beta3+...+x100*beta100**. This calculation will be__repeated for the 200 observations__.So my question is (1) how to write the code to calculate the above formula, and (2) in a general way, if the number of my matrix values is not exact the same as the number of variables in the database, for example, I have x1-x100 variables, but I have the matrix with values beta1-beta105, x variables could be partly matched to matrix according to their names, how shall I write the code?

Thank you very much.

## Comment