3.7.111 WRITE variable. Great Migrations LLC PROMULA Application Development System
Advertisement
Advertisement
Promula Application Development System User's Manual
The READ VALUE MAIN statement will read in the values of the segment MAIN's variables that were stored by the last
WRITE VALUE MAIN statement.
READ VALUE MAIN
WRITE a
The value of variable A = 10
3.7.111 WRITE variable
Purpose:
Shows the information in a variable.
Syntax:
WRITE var[fmt][ORDER(sets)][TITLE(title)][DISPLAY(dvar)][option]
Remarks: var fmt is the identifier of a variable.
is a format specification to indicate the position of the display, the width of the values displayed, and the number of decimals in real values, as follows:
\p:w:d where p is an integer specifying the width in characters for row descriptors. The default width is the width specifications of the row descriptors related to the set subscripting the rows of the display.
w is an integer specifying the width in characters for each column of values. The default is the width specification in the definition of var
. A negative width parameter left justifies the values of var in each column. d is an integer specifying the number of decimals to display for real numeric values. The default is the decimal specification (if applicable) in the definition of var
. If d is an "E", the values of var will be displayed in exponential notation (base-10), and will show seven digits and six decimal places.
If omitted, w and d are the parameters specified in the TYPE specification for var
, and p is the width specifications of the row descriptors related to the set subscripting the rows of the display.
sets title is a list of the sets classifying the values of var
. The order of the sets in this list specifies the structure of the display: the first set classifies the rows of the display, the second set the columns, and the third to last sets classify the pages of the display. The keyword ORDER is optional; if it is omitted, sets must follow immediately after the optional format specification.
is any text you wish to show as a title for the table. The title may include variables, and other format characters according to the rules defined in the WRITE text statement.
294
Promula Application Development System User's Manual
dvar option is a variable used to control the display of variable var
.
dvar should be subscripted by the set that defines the rows of the display. PROMULA will display values of var only for those rows corresponding to elements of dvar that contain nonzero values. See Example in the section on the BROWSE variable statement.
is one of the following WRITE variable options:
TOTAL[(
sets
)]
PERCENT(
CHANGE(
MOVING(
n
GROWTH(
n set
)
n
)
)
)
displays totals over the selected sets along with values of var
. If sets is omitted, all the marginal and grand totals for var will be displayed.
displays the percent distribution of the total over set of var
.
The CHANGE option allows the user to show a table of percent change in time series data for a previously defined time series dataset or array.
The percent change for time t is computed from values for time t and t-1
, where t and t-1 are two consecutive selections of the time set. The selections depend on the current local setting of the set. They may or may not be consecutive time points. There may be more than one time unit between them.
Following the keyword, CHANGE, a real number within parentheses is required. It represents the number of time units to be used in computing percent change. Internally it is divided by the difference in time values for selections t and t-1
.
Suppose values for 1970 and 1975 are used in computing the percent change. That is, the user has selected these years for computation and output generation. Also s/he wants to compute an annual percent change, so one time unit (a year) is designated on the CHANGE option (CHANGE(1)). The change for 1975 is computed as the difference in values for 1970 and 1975, divided by the 1970 value, and multiplied by .2
(for annual change). A factor of 100 gives the final result as a percent change from
1970 to 1975 in one year increments.
In the tabular display the words, Percent Change in, are placed in front of the original title (from the variable definition). If the TITLE option is used with the CHANGE option no words are prefixed.
The GROWTH option allows the user to show a table of growth rates in time series data for a previously defined time series dataset or array. A time series dataset or array is one which is defined by a time series set. The growth rate for time t is computed from values for time t and t-1
, where t and t-1 are defined as above.
Following the keyword, GROWTH, a real number within parentheses is required and stands for the number of time units between growth rates. Internally it is divided by the difference in time values for selected t and t-1
.
Suppose the user has selected 1970 and 1975 and wishes to show annual growth rates
(GROWTH(1)). The growth rate for 1975 is computed as a quotient — value for 1975 divided by value for 1970 — raised to the power .2
(1.0/(1975-1970)). One is subtracted from this quantity to get a growth rate and a factor of 100 gives the final result as a percent rate from 1970 to 1975 in one year increments.
In the tabular display, the words, Growth Rate in, are placed in front of the original title unless the TITLE option is specified.
The MOVING option allows the user to show a table of moving averages in time series data for a previously defined time series array. Following the keyword MOVING, an
295
Promula Application Development System User's Manual
integer, n, within parentheses, gives the number of single unit time increments over which the moving average is computed. The moving average for time t is computed from values for time t,...,t-(n-1)
, where the t
's are consecutive time points. They are not consecutive time set selections, based on a local setting of the time set. Rather, they are time points as defined initially by the time values related to the set subscripting var
.
Suppose the user has selected a five year moving average (MOVING(5)) based on an annual time series from 1970 to 1990, and he wishes to show only 1975, 1980, 1985,
1990 moving averages. The average for 1990 is computed as the sum of values from
1986 to 1990 divided by the number of time points as defined initially by the TIME option on the set definition.
In the tabular display the words, Moving Average for, are placed in front of the original title unless the TITLE option is specified.
Example:
DEFINE SET row(3) col(2) pag(2)
END SET
DEFINE VARIABLE a(row,col,pag) "A 3-Dimensional Array"
END VARIABLE a(i,j,k)=i*j*k
Given the defintions above, the statements
WRITE a TITLE ("Unformatted Display of variable A")
WRITE a\6:10:2(pag,col,row) TOTAL(col) TITLE(//"Formatted Display of variable A") produce the following output.
Unformatted Display of variable A
ROW(1)
ROW(2)
ROW(3)
PAG(1)
COL(1) COL(2)
1
2
3
2
4
6
ROW(1)
ROW(2)
ROW(3)
PAG(2)
COL(1) COL(2)
2
4
6
4
8
12
Formatted Display of variable A
ROW(1)
PAG(1)
PAG(2)
Total
3.00
6.00
COL(1)
1.00
2.00
COL(2)
2.00
4.00
296
Promula Application Development System User's Manual
PAG(1)
PAG(2)
PAG(1)
PAG(2)
ROW(2)
Total
6.00
12.00
COL(1)
2.00
4.00
ROW(3)
Total
9.00
18.00
COL(1)
3.00
6.00
COL(2)
4.00
8.00
COL(2)
6.00
12.00
Examples of the other WRITE VARIABLE options are presented with the discussion of the BROWSE VARIABLE statement.
297
Download
Advertisement