Dear Statalist,

I am trying to create a simple descriptive table using mata for the first time.

My aim is to count how many project deals and project locations are in each country with "country names" as rows and two columns for "number of project deals" and "number of project locations".

I tried the following code but I always get a "invalid syntax" error message:


Code:
matrix define X = J(3,2,.)
matrix rownames X = "Country1" "Country2" "All"

local varlist deals location
local i = 1
foreach var of `varlist' {


tempname A_`var'
tab Country, sum(`var') freq
mat A_`var' = e(b)
mat O__`var' = e(obs)

mat X[1,`i'] = el(A_`var',1,1)
mat X[2,`i'] = el(A_`var',1,2)
mat X[3,`i'] = el(O_`var',1,3)
}

frmttable, statmat(X)

Thanks a lot for any help!

Warm greetings,
Bianca