Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Eviews5 / EViews5 / Docs / EViews 5 Users Guide.pdf
Скачиваний:
152
Добавлен:
23.03.2015
Размер:
11.51 Mб
Скачать

Appendix B. Wildcards

EViews supports the use of wildcard characters in a variety of situations where you need to enter a list of objects or a list of series. For example, you can use wildcards to:

fetch, store, copy, rename or delete a list of objects

specify a group object

query a database by name or filter the workfile display

The following discussion describes some of the issues involved in the use of wildcard characters and expressions.

Wildcard Expressions

There are two wildcard characters: “*” and “?”. The wildcard character “*” matches zero or more characters in a name, and the wildcard “?” matches any single character in a name.

For example, you can use the wildcard expression “GD*” to refer to all objects whose names begin with the characters “GD”. The series GD, GDP, GD_F will be included in this list GGD, GPD will not. If you use the expression GD?, EViews will interpret this as a list of all objects with three character names beginning with the string “GD”: GDP and GD2 will be included, but GD, GD_2 will not.

You can instruct EViews to match a fixed number of characters by using as many “?” wildcard characters as necessary. For example, EViews will interpret “??GDP” as matching all objects with names that begin with any two characters followed by the string “GDP”. USGDP and F_GDP will be included but GDP, GGDP, GDPUS will not.

You can also mix the different wildcard characters in an expression. For example, you can use the expression “*GDP?” to refer to any object that ends with the string “GDP” and an arbitrary character. Both GDP_1, USGDP_F will be included.

Using Wildcard Expressions

Wildcard expressions may be used in filtering the workfile display (see “Filtering the Workfile Directory Display” on page 59), in selected EViews commands, and in creating a group object.

The following commands support the use of wildcards: show, store, fetch, copy, rename and delete.

946—Appendix B. Wildcards

To create a group using wildcards, simply select Object/New Object.../Group, and enter the expression, EViews will first expand the expression, and then attempt to create a group using the corresponding list of series. For example, entering the list,

y x*

will create a group comprised of Y and all series beginning with the letter X. Alternatively, you can enter the command:

group g1 x* y?? c

defines a group G1, consisting of all of the series matching “X*”, and all series beginning with the letter “Y” followed by two arbitrary characters.

When making a group, EViews will only select series objects which match the given name pattern and will place these objects in the group.

Once created, these groups may be used anywhere that EViews takes a group as input. For example, if you have a series of dummy variables, DUM1, DUM2, DUM3, …, DUM9, that you wish to enter in a regression, you can create a group containing the dummy variables, and then enter the group in the regression:

group gdum dum?

equation eq1.ls y x z gdum

will run the appropriate regression. Note that we are assuming that the dummy variables are the only series objects which match the wildcard expression DUM?.

Source and Destination Patterns

When wildcards are used during copy and rename operations, a pattern must be provided for both the source and the destination. The destination pattern must always conform to the source pattern in that the number and order of wildcard characters must be exactly the same between the two. For example, the patterns,

Source Pattern

Destination Pattern

 

 

x*

y*

 

 

*c

b*

 

 

x*12?

yz*f?abc

 

 

which conform to each other, while these patterns do not:

Source Pattern

Destination Pattern

 

 

a*

b

 

 

Resolving Ambiguities—947

*x

?y

 

 

x*y*

*x*y*

 

 

When using wildcards, the new destination name is formed by replacing each wildcard in the destination pattern by the characters from the source name that matched the corresponding wildcard in the source pattern. This allows you to both add and remove characters from the source name during the copy or rename process. Some examples should make this clear:

Source Pattern

Destination Pattern

Source Name

Destination Name

 

 

 

 

*_base

*_jan

x_base

x_jan

 

 

 

 

us_*

*

us_gdp

gdp

 

 

 

 

x?

x?f

x1

x1f

 

 

 

 

*_*

**f

us_gdp

usgdpf

 

 

 

 

??*f

??_*

usgdpf

us_gdp

 

 

 

 

Note, as shown in the second example, that a simple asterisk for the destination pattern will result in characters being removed from the source name when forming the destination name. To copy objects between containers preserving the existing name, either repeat the source pattern as the destination pattern,

copy x* db1::x*

or omit the destination pattern entirely,

copy x* db1::

Resolving Ambiguities

Note that an ambiguity can arise with wildcard characters since both “*” and “?” have multiple uses. The “*” character may be interpreted as either a multiplication operator or a wildcard character. The “?” character serves as both the single character wildcard and the pool cross section identifier.

Wildcard versus Multiplication

There is a potential for ambiguity in the use of the wildcard character “*”.

Suppose you have a workfile with the series X, X2, Y, XYA, XY2. There are then two interpretations of the wildcard expression “X*2”. The expression may be interpreted as an autoseries representing X multiplied by 2. Alternatively, the expression may be used as a wildcard expression, referring to the series X2 and XY2.

948—Appendix B. Wildcards

Note that there is only an ambiguity when the character is used in the middle of an expression, not when the wildcard character “*” is used at the beginning or end of an expression. EViews uses the following rules to determine the interpretation of ambiguous expressions:

EViews first tests to see whether the expression represents a valid series expression. If so, the expression is treated as an auto-series. If it is not a valid series expression, then EViews will treat the “*” as a wildcard character. For example,

y*x

2*x

are interpreted as auto-series, while,

*x

x*a

are interpreted as wildcard expressions.

You can force EViews to treat “*” as a wildcard by preceding the character with another “*”. Thus, expressions containing “**” will always be treated as wildcard expressions. For example, the expression:

x**2

unambiguously refers to all objects with names beginning with “X” and ending with “2”. Note that the use of “**” does not conflict with the EViews exponentiation operator “^”.

You can instruct EViews to treat “*” as a series expression operator by enclosing the expression (or any subexpression) in parentheses. For example:

(y*x)

always refers to X times Y.

We strongly encourage you to resolve the ambiguity by using parentheses to denote series expressions, and double asterisks to denote wildcards (in the middle of expressions), whenever you create a group. This is especially true when group creation occurs in a program; otherwise the behavior of the program will be difficult to predict since it will change as the names of other objects in the workfile change.

Wildcard versus Pool Identifier

The “?” wildcard character is used both to match any single character in a pattern and as a place-holder for the cross-section identifier in pool objects.

EViews resolves this ambiguity by not allowing the wildcard interpretation of “?” in any expression involving a pool object or entered into a pool dialog. “?” is used exclusively as

Wildcard versus Pool Identifier—949

a cross-section identifier. For example, suppose that you have the pool object POOL1. Then, the expression,

pool1.est y? x? c

is a regression of the pool variable Y? on the pool variable X?, and,

pool1.delete x?

deletes all of the series in the pool series X?. There is no ambiguity in the interpretation of these expressions since they both involve POOL1.

Similarly, when used apart from a pool object, the “?” is interpreted as a wildcard character. Thus,

delete x?

unambiguously deletes all of the series matching “X?”.

950—Appendix B. Wildcards

Соседние файлы в папке Docs