Hey I want to write a Mata function with an if condition
function sum {
sum(x)
if sum(x) == 0 {
sum(y)
is that possible?
function sum {
sum(x)
if sum(x) == 0 {
sum(y)
is that possible?
. mata ------------------------------------------------- mata (type end to exit) - : x = (0,0,0) : y = (1,2,3) : result = sum(x) == 0 ? sum(y) : sum(x) : result 6
real myresult (real vector X, real vector Y) { return(sum(X) == 0? sum(Y) : sum (X)) } myresult(x, y) 6
Comment