Command Reference : EViews Programming : Program Arguments
  
Program Arguments
Program arguments are special string variables that are passed to your program when you run the program. Arguments allow you to change the value of string variables every time you run the program. You may use them in any context where a string variable is appropriate. Any number of arguments may be included in a program. The individual arguments will be available in the string variables “%0”, “%1”, “%2”, and so on; the “%ARGS” variable will contain a space delimited list of all the arguments passed into the program.
When you run a program that takes arguments, you may supply the values for the arguments. If you use the Run button or File/Run, you will see a dialog box where you can type in the values of the arguments. If you use the run or exec command, you may list the arguments consecutively after the name of the program.
For example, suppose we have a program named “REGPROG”:
equation eq1
smpl 1980q3 1994q1
eq1.ls {%0} c {%1} {%1}(-1) time
To run REGPROG from the command line with %0=“lgdp” and %1=“m1”, we enter
run regprog lgdp m1
This program performs a regression of the variable LGDP, on C, M1, M1(-1), and TIME, by executing the command:
eq1.ls lgdp c m1 m1(-1) time
Alternatively, you can run this program by clicking on the Run button on the program window, or selecting File/Run.... In the Run Program dialog box that appears, type the name of the program in the Program name or path field and enter the values of the arguments in the Program arguments field. For this example, type “regprog” for the name of the program, and “lgdp” and “m1” for the arguments.
Any arguments in your program that are not initialized in the Run Program dialog or run command are treated as empty string variables. For example, suppose you have a one-line program named “REGRESS”:
equation eq1.ls y c time {%0} {%1} {%2} {%3} {%4} {%5} {%6} {%7} {%8}
The command,
exec regress x x(-1) x(-2)
executes
equation eq1.ls y c time x x(-1) x(-2)
while the command,
exec regress
executes
ls y c time
In both cases, EViews ignores arguments that are not included in your run command.
As a last example, we repeat our simple forecasting program from above, but use arguments to simplify our work. Suppose you have the program “MYPROG”:
wfcreate(wf={%0}) m 1968m3 1997m6
fetch progdemo::{%1}
smpl 1968m5 1992m12
equation reg1.ls {%1} c {%1}(-1)
reg1.makeresid {%1}res
smpl 1993m1 1997m6
reg1.forecast {%1}fit
freeze({%1}plot) {%1}fit.line
save
The results of running the two example programs at the start of this chapter can be duplicated by executing MYPROG with arguments:
exec myprog myhouse hsf
and
exec myprog mysp500 fspcom