RATS 10.1
RATS 10.1

Instructions /

SOURCE Instruction

Home Page

← Previous Next →

SOURCE( options )  filename

Switches input source to indicated file until its end of file is reached. Control then returns to current source. SOURCE files can be nested and switches to SOURCE files can be made from within a compiled section. SOURCE is most often used for reading in PROCEDURES. You generally don't need to use SOURCE when you are using a standard procedure (such as @DFUNIT), as RATS will locate and pull those in as needed.

Parameters

filename

name of the file. If there is no path (directory) on the file name, the first search location is the directory of its parent, if this is a SOURCE inside another SOURCE file. If that doesn't apply, the current working directory is checked, which typically means the directory where the program file being run is located. And if it isn't there, the procedure search path(s) will be checked.

Options

ECHO/[NOECHO]

Normally, RATS won’t show the lines in the SOURCE file as it reads them. Use ECHO if you want to see them. Note that the default setting is now NOECHO.

 

KEY="key for decrypting file"

Contact Estima if you want to obtain software to encrypt source files.

 

STATUS=INTEGER variable returning status [unused]

If you use the STATUS option, SOURCE will set the variable you supply to 1 if the file was successfully opened, or 0 if it was not.

Notes

SOURCE has two primary uses:

You can save on separate files PROCEDURES and FUNCTIONS, or groups of RATS instructions you use often, and SOURCE them into different programs.

You can save your initial instructions: CALENDAR, ALLOCATE, DATA, and transformations, and start programs by SOURCEing these, rather than repeating them in each program.

 

If you use SOURCE within a compiled section, you should note that RATS does not execute the SOURCE instruction during the compilation phase; it is not like an “include” allowed in many programming languages. During the execution phase, RATS temporarily stops executing the compiled code to execute the instructions on the SOURCE file, then switches back. Because the file is not processed during the compilation phase, it cannot include references to procedure parameters or local variables.

Examples

source prsetup.src

 

This is used in several examples of simultaneous equations to pull in the instructions which read the data and estimate the model.



 

source logmvskewt.src

dec vector logxi(n)

nonlin(parmset=skewparms) nu logxi

nonlin(parmset=noskewparms) nu

frml logl = hx=DCCOneStepUpdate(t),$

  %logmvskewt(inv(%chol(hx))*%xt(u,t),%exp(logxi),nu)-.5*log(%det(hx))

 

%LOGMVSKEWT is a FUNCTION rather than a PROCEDURE. Unlike PROCEDURES, FUNCTIONS aren't pulled in automatically by RATS.

 


Copyright © 2025 Thomas A. Doan