Stata Status: Beginner
I have declared a local variable inside my function. And whenever I reference it for a mathematical operation, it gives me the error 'invalid name'. A snippet of the code is given below:
I have put a trace and it stops at the gen v line with 'y: invalid name'. I have tried using `y', $y, y. Nothing works.
Note: The variable y has content, it is not 0. The matrix from ix and y have dimensions that allow the :* operation. nt is not empty.
Where am I going wrong?
I have declared a local variable inside my function. And whenever I reference it for a mathematical operation, it gives me the error 'invalid name'. A snippet of the code is given below:
Code:
cap program drop ix
program ix, rclass
version 15.1
syntax varlist(numeric min=1 max=1), ix(string)
local y `:word 1 of `varlist''
sum `y'
.
.
.
tempname nt
matrix nt = `ix'
gen v = y:*nt
.
.
.
//return lists
end
Note: The variable y has content, it is not 0. The matrix from ix and y have dimensions that allow the :* operation. nt is not empty.
Where am I going wrong?

Comment