RATS 11
RATS 11

Instructions /

DISPLAY Instruction

Home Page

← Previous Next →

DISPLAY( options )   variables, strings ('labels'), position codes, picture codes

Used for displaying scalars, individual entries of series and arrays, and other types of variables and expressions in a flexible way.
 

You can use ? in place of the instruction name if you don't use an option field.

Parameters

variables

These can be variables or expressions to be evaluated. You can also display EQUATIONs, MODELs or PARMSETs, and SERIES of (almost) any type, though PRINT is generally much better for working series.

strings

strings of characters ('...')

position codes

@n, @+n or @-n alters the placement of the field immediately following it (at position n, n positions to the right, n positions to the left, respectively)

picture codes

Picture codes set the format for subsequent values to be displayed. They take the form #### for integers, or ####, ####.##, or *.## for reals. A code with no decimal point causes the number to be printed right-justified in a field whose width is the number of # signs. A code with a decimal point produces a number the width of the total string, with the decimal point in the indicated location. If you use * left of the decimal point, it uses as many places as needed to show the number and no more.

 

Unlike most other instructions, the picture codes are not put in "...".
 

tab codes

A tab field takes the form @@[flag] spacing. The flags are:

. decimal
> right
< left (the default if no flag is included)
^ center

The spacing starts relative to the current position.

Options

UNIT=[OUTPUT]/COPY/other user-defined

unit to which line is written

 

DELIMITED=[NONE]/TAB/COMMA/SEMICOLON

By default (with the NONE choice), output in a DISPLAY instruction is separated by blank spaces. This option allows you to generate tab, comma, or semicolon-delimited output instead. This works when outputting to the screen, but is most useful when using the UNIT option to output to a text file.

 

WIDTH=maximum width of a line [255]

This controls the width of the content of a line. If the information exceeds that length, one line is finished and a new one started.

 

STORE=string variable [unused]

This saves the created line in string variable rather than displaying it. You can use this variable, for instance, as a header for a graph, though you can often do the same operation with a COMPUTE instruction.

 

HOLD/[NOHOLD]

If you use HOLD, DISPLAY creates the string and waits for another DISPLAY instruction to add more to it. This can be useful when the number of objects that you want to display is not known in advance, but REPORT is generally a better choice.

Examples

display @@.12 *.## xvect

 

will display the elements of XVECT with the first decimal place in position 12, the second at 24, etc; each number displayed with two digits right of the decimal point.


 

? a b c

? "This text will appear on the screen"

 

will show the values of a, b and c on one line, then, "This text..." on the next.


 

open copy text.out

display(unit=copy) "This text will be added to the file TEXT.OUT"


 

 

display  "Test statistic is" ((rssr-rssu)/q)/(rssu/%ndf)

display  "Degrees of freedom are"  q   "and"  %ndf
 

which will produce something like
 

Test statistic is             3.92092

Degrees of freedom are       13 and         123

 

If you want to make this look a little cleaner (when it’s displayed), you could do something like

 

display "F(" q "," %ndf  ") =" ((rssr-rssu)/q)/(rssu/%ndf)


 

which will give you


 

F( 13 , 123 ) =       3.92092
 

A further improvement (which you might do if you’re writing this as part of a procedure which others will use), is to use a picture code to squeeze out the extra spaces and drop some of the excess digits on the result. This:

 

display "F("+q+","+%ndf +") =" *.### ((rssr-rssu)/q)/(rssu/%ndf)

 

will produce

 

F(13,123) = 3.921


 

@johmle(lags=6,det=rc,cv=cvector)

# ftbs3 ftb12 fcm7

equation(coeffs=cvector) ecteq *

# ftbs3 ftb12 fcm7 constant

?ecteq

 

estimates a cointegrating vector using @JOHMLE, creates an EQUATION based upon it, and displays that. This is how DISPLAY shows an EQUATION:

 

No dependent variable

     Variable            Coeff

***********************************

1.   FTBS3            -3.154122986

2.   FTB12             3.132881615

3.   FCM7             -0.321837817

4.   Constant          0.619010214


 

dec vect[labels] methodlabl(n)

do i=1,n

   compute methodlabl(i)="Method "+i

end do i

display @@^12 methodlabl

 

shows the strings “Method 1”, “Method 2”, ... centered every 12 positions:
 

     Method 1    Method 2    Method 3    Method 4

 

Note that it’s often easier to use REPORT rather than complicated DISPLAY instructions.


 


Copyright © 2025 Thomas A. Doan