Object Reference : Object View and Procedure Reference : Model
  
 
replacevar
Replace all instances of a variable in the text specification of a model with a different variable.
Syntax
model_name.replacevar oldvar newvar
Replacevar can only replace variables defined by a text specification inside the model. It will not replace variables contained inside linked objects. Note that replacevar does not do a simple text substitution, and is capable of determining full variable names from other pieces of text.
Examples
Model m1
M1.append y = 3*x
M1.replacevar x z
this example creates a model, M1, and adds a text specification for the variable Y, setting it equal to 3*X. It then replaces all occurrences of X with Z, changing the specification of Y to be equal to 3*Z.
M1.append y=3*log(x(-2))
m1.append w = 4*x1
M1.replacevar x z
this example generates a specification for Y, setting it equal to 3 times the log of the twice lagged value of X, and a specification for W, setting it equal to 4 times X1.  It then replaces all instances of the variable X with the variable Z, changing the specification of Y to be equal to 3 times the log of twice lagged Z.  Note that the specification of W does not change, since X1 is a different variable from X.
Cross-references