RENAME

<< Click to Display Table of Contents >>

Navigation:  Gekko User Manual > Gekko statements >

RENAME

Previous pageReturn to chapter overviewNext page

RENAME changes names of variables inside a databank. If the rename operation involves two different databanks, the variable is moved between the banks (and possibly also renamed, as in for instance rename b1:x as b2:y; between the two databanks b1 and b2).

 

Note that 'naked' wildcards are allowed in this statement, so you may for instance use a*b?c as wildcard instead of the more cumbersome {'a*b?c'}.

 

 


 

Syntax

 

rename < BANK=... > variables1  AS  variables2;

 

BANK=

(Optional). A databank name indicating where the timeseries are located.

variables1

Variable name(s) or list(s)

variables2

Variable name(s) or list(s)

 

If a databank name is not provided, the variable is not searched for in other databanks than the first-position databank.

Looping: with a list like for instance #= a, b;, you may use rename x{#m} to y{#m}; to rename xa to ya, and xb to yb.

 


 

Example

 

Consider the two series x1 and x2 residing in the first-position databank. If we want to rename those series into y1 and y2, we could use:

 

rename x1, x2 as y1, y2;

 

Lists can be used instead:

 

#= x1, x2;  //or: ('x1', 'x2')
#= y1, y2;
rename {#a} as {#b};  //without the {}-curlies, the #a list itself is renamed to #b!

 

Rename works across banks, too, in reality moving the variable:

 

rename b1:x as b2:x;  //moving between banks

 

Wildcards can be used like this:

 

rename x*2 as y_*;

 

All variables starting with x and ending with 2 will obtain prefix y_.

 

See the similar COPY statement for more examples. RENAME is in reality similar to a COPY where the original object is deleted after copying. Also see the INDEX statement and the wildcard page regarding the syntax rules of wildcards.

 

 


 

Note

 

When using two lists of names, the lists must have equal length.

 

If preferred, you may use rename ... to ... instead of rename ... as ... .

 

RENAME does not accept array-series indexes yet, but you may use COPY followed by DELETE to the same effect.

 

 


 

Related statements

 

COPY, DELETE, INDEX