As I run the following program for vartia algorithm always got the error "Undefined symbol: 't' on line 30". How can I solve it? Thanks.

```
clear p, y, s;
p0 = 0.75;
pt = 1.5;
y0 = 720;
num = 100;
let b = 4.95 -14.22 .082;
call vartia;
end;
proc q(x,b);
local p, y, z;
p = x[1];
y = x[2];
z = b[1] + b[2]*p + b[3]*y;
retp (z);
endp;
@ ======================================@
proc (0) = vartia;
local del, p, np, ny, y, tcv, h, g, cv, dwl, dhdp, icnt, j, oldy, newy, xc, xt, ybase;
tcv = y0;
ybase = y0;
del = (pt-p0)/num;
p = p0;
y = y0;
np = rows(p);
ny = np+1;
xc = q(p|y,b);
j = 2;
do until j>num;
icnt= 0;
cont:
icnt = icnt + t;
p = p0 + (j-1)*del;
oldy = y;
xt = q(p|y,b);
cv= 0.5*(xt+xc)' del;
newy = cv + ybase;
y = newy;
if (icnt == 500);
"Not converged";
end;
endif ;
xc = xt;
if (abs(newy-oldy)>.0001);
goto cont;
endif;
ybase=newy;
j=t+1;
endo;
tcv = y- tcv;
dwl = tcv-(pt-p0)'q(pt|y,b);
"TVC=" tcv;
"DWL=" dwl;
"stder TCV=" sqrt(x);
endp;
@=======================================@
```

## 1 Answer

0

There are a couple of problems in this program. The first is related to '`t`', which is only referenced on two lines:

`icnt = icnt + t;`

and

`j=t+1;`

The problem is that the value of '`t`' is never set. '`t`' needs to be assigned a value before it is used the first time.

The second problem is that '`x`' is used on this line without ever being defined:

`"stder TCV=" sqrt(x);`

The other uses of '`x`' are in this procedure:

```
proc q(x,b);
local p, y, z;
p = x[1];
y = x[2];
z = b[1] + b[2]*p + b[3]*y;
retp (z);
endp;
```

Since '`x`' is passed in to the procedure '`q`' as an input, it is a local variable. This '`x`' exists only inside of the '`q`' procedure.

So to make this procedure work correctly, you need to set '`t`' and '`x`' to some appropriate value before the program tries to use them.