Programming

CHAPTER 6: EViews Programming

Create a new program

program program_name Generally each line corresponds to a command so each can be executed pressing enter. One can also execute selected batches by pressing crtl+Enter.

To see line numbers press wrap +/- and select Display line numbers.

Manually break long lines using the _ character:

This will execute as a single line of code (but _ must be the very LAST character on the line for this to work)

Comments are formed using the apostrophe before the text. If you wish to commend out (or uncomment) a code block right-mouse click and select Comment Selection or Uncomment Selection respectively.

Auto format by selecting right-mouse click and select Format Selection.

The Snapshot button creates a manual snapshot of the code (in case things go wrong).

Open a program:

open program_name.prg

OR

open "full file path"

Hit the run button to execute the entire program (each line in order of appearance) or use the run command. EG

run program_name

OR

run full_path_name arg1 arg2 arg 3 (see PDF page 132)

To run verbose and specify the max number of errors use

run(v, 500) program_name

To do so quietly use

run(q, 500) program_name

Note we can run programs and chose which variables to use at run time. See book page 124, PDF page 133.

run program_name(op1, opt2, opt3=k) arg0 arg1 arg1 (%0 %1 and %2 respectively).

Program Variables: two types Control variables (numeric) String variables Control variables are written with a bang at the front (! = bang)

EG

!x !1 !i !counter

These are assigned using the = sign and are not stored as variables.

NOTE: control variables are used in programs via text substitution. If EViews encounters a control variable in a program it substitutes the text value of that variable into the program. One of the implications of the text substitution is that you may lose some numeric accuracy when using a program variable due to the conversion in to and out of a text representation of the number.

String program variables are text rather than numeric and are stored for temporraty use using the % character

%value = "value in millions of US dollars"

Used to help build up command text, variable names, or other string values. An assigned string variable may appear in any expression in place of the underlying string.