.. index:: single: G7 Reference Manual; I single: G7 Command; ic single: G7 Command; id single: G7 Command; if-else single: G7 Command; index single: G7 Command; ipch single: G7 Command; intvar *G7* Commands: I ================ .. _G7RMic: **ic ** The *ic* (insert comment) command is used to put comments (lines beginning with '#') into save files. This can be useful when you are writing a *G7* data file and would like to put titles or comments next to each data series. Related Topics: Comments, :ref:`save ` .. _G7RMid: **id ** The *id* command has no effect in *G7* but when passed to *Build* puts all variables (without computing the left-side one) into the workspace and puts an identity into the model. The syntax for the expression is the same as the *f* command. Example:: ti 4. Additions and Alterations fex cst4h = cst4$/hhld r cst4h = ddi87h, rcmor, ratdif[1], hhead, singsh id cst4$ = cst4h*hhld gr * This example is one of the construction equations from the IdLift model. The *id* statement is used here so that there will be a statement in the model to create cst4$ after calculating the regression. However, we don't want the regression runstream to recalculate the value of cst4$ and put it into the workspace bank since the proper values of this series already were put into the bank by the previous *fex* statement. Related Topics: Model Building, :ref:`f `, :ref:`fdup `, :ref:`fex ` .. _G7RMif: | **if( [comparisons] ){ [...] }** | **[ else if( [comparisons] ){ [...] } ]** | **[ else{ [...] } ]** | The *if* command evaluates a series of logical expressions. If the arguments are true, then the following block of code, contained in a set of brackets, is executed. If the argument is false, then *else if* statements are processed in the same way. If all *if* and *else if* arguments are false, then the code following the final *else* command is processed. Three types of comparisons are allowed. First, a number may be compared to a second number. Second, a single number may be given and implicitly compared to zero. Finally, a string may be compared to a second string. Valid comparisons between two strings, with the comparison based on the lexicographical ordering, or between two numbers are :<: is LESS THAN :<=: is LESS THAN OR EQUAL TO :==: is EQUALS :>=: is GREATER THAN OR EQUAL TO :>: is GREATER THAN :!=: is NOT EQUALS :!: is the logical negation operator. If given before a number, then the result is FALSE if the number is nonzero and the result is TRUE if the number is zero. If given before a set of parentheses, then the result is FALSE if the expression within the parentheses is TRUE, and the result is TRUE if the expression within the parentheses is FALSE. Additional string comparison tools include: **strcmpi(,)** Compares string1 and string2, without case sensitivity. Value is TRUE if strings match. **strncmp(,,)** Compares the first N characters of string1 and string2, with case sensitivity. Value is TRUE if the first N characters of the strings match. **strncmpi(,,)** Compares the first N characters of string1 and string2, without case sensitivity. Value is TRUE if the first N characters of strings match. .. note:: These routines have been replaced by the %strcmpi(), %strncmp(), and %strncmpi() routines. Multiple comparisons may be performed, with the following operators joining them :||: Logical OR, which returns TRUE if either the left hand side or the right hand side is TRUE. :&&: Logical AND, which returns TRUE if both the left hand side and the right hand sides are TRUE, and returns FALSE otherwise. The following list of keywords may be used: :NARGS: The number of arguments passed to a function or to an add file. :exists(): The presence of a series in a data bank can be tested. "exists(a.x)" returns true if variable x is found in bank a. :eval(series, date): A number may be retrieved from a data bank for comparison. The value of series in period date is retrieved, either from the workspace or from the specified bank. The value may be compared to a scalar or to a second eval result. .. note:: These routines have been replaced by the %NARGS, :ref:`%exists() `, and %getval() routines. Comparisons may be evaluated as a group by surrounding them with parentheses. Blocks of code following the arguments must be surrounded by brackets {}. Examples:: if( 1 - 2 < -0.5 ) { ic Subtraction } if( 2 < 3 && 3 <= 4){ ic Multiple evaluations } if( 2 < 3 || 3 <= 4){ ic Multiple evaluations with OR } if( 1 == 1 ) { ic Equality } else if( !0 ) { ic Else if and negation } else { ic Else } if( D != N ){ ic String inequality comparisons } if( D <= N ){ ic String less than or equal to } if( mod(7,2) == 1 ) { ic Modulo arithmetic } do{ if( %1 == 3){ ic Continuing on Iteration %1 continue } if( %1 == 5 ){ ic Breaking on Iteration 5 break } if( %1 > 5 ){ return ERR } }( 1-10 ) .. _G7RMindex: | **(in)dex ** | **(in)dex ** | A quick way to fill in values of a vector so that they all grow at the same rate is to use of the *index* command. It is used in conjunction with a guide series, a previously established single-variable time series, whose growth rates will be applied to the elements of the vector. It acts over the range of the currently specified *fdates*. For example, if "years" is the name of a series of the numbers of years -- 1980, 1981, etc. -- then to make all elements of the vector "pce" grow by 2.0 percent per year from 1999 to 2010, the following commands can be used:: f g02 = @exp(0.02*(years - 1980)) index 1999 g02 pce The use of groups is allowed in the names of series to be affected. To use groups, we must first use the *load* command to load the vector into memory. For example, to move only the sectors 1,7, and 9 of pce, we could do:: group 1 7 9 load pce index 1999 g02 : Recall that *:* is the name of the dynamic group, if it exists. To move just the sectors in the static or named group ConsumerDurables, the command would be:: load pce index 1999 g02 :ConsumerDurables To index only a specific vector element like "exp2", the command would be :: index 1999 g02 exp2 Provision of a vector or matrix name without a sector number means to move the whole vector or matrix by the index. This device can be used to project a whole input-output matrix, say, am, to be constant, as in this example:: fdates 1998 2020 f one = 1 index 1998 one am A matrix name followed without a space by a sector number means to move that row of the matrix by the guide. Thus, "am2" means move the second row of the am matrix by the guide. If is the name of a vector and is the name of a matrix, then the rows of the matrix are indexed by the corresponding elements of the vector. If an element of the vector is zero in the base year, the corresponding rows of the matrix are unchanged. This feature works for both standard and packed matrices. It can be used to apply across-the-row coefficient change to an input-output matrix. For example, if mover is a vector, we can make each row of the am matrix follow the index of the corresponding element of mover with:: fdates 1998 2020 index 1998 movers am In applying this sort of across-the-row coefficient change, one usually does not want it to apply to the diagonal elements, for they have little to do with the technological changes affecting other coefficients. For this, we would use the *diagextract* and *diaginsert* commands to save the diagonal first, then do the indexing, and then put the diagonal back into the matrix, as in the following example:: fdates 1998 2020 diagextract am diags index 1998 movers am diaginsert am diags Related Topics: :ref:`diagextract `, :ref:`diaginsert `, :ref:`fdates `, :ref:`group `, :ref:`rowscale ` .. _G7RMipch: **ipch []