User’s Guide : EViews Fundamentals : Working with Data (Advanced) : Alpha Series
  
Alpha Series
 
Declaring an Alpha Series
Editing an Alpha Series
Assigning values to Alpha Series
Working with Alpha Series
Generating Numeric Values
Additional Issues
The Spreadsheet View
Auto-series
An alpha series object contains a set of observations on alphanumeric string values. Alpha series should be used when you wish to work with variables that contain alphanumeric data, such as names, addresses, and other text. If any of these types of data were entered into an ordinary series, EViews will replace the string with the numeric missing value, NA.
You may, for example, have an alpha series that contains the two-character U.S. Postal Service abbreviations for the 50 states, D.C., and Puerto Rico. Here, we show the alpha series, STATE, that contains the appropriate 2-character string values. STATE will be identified in the workfile with the alpha series icon labeled “abc”, and by the designation Alpha in the titlebar of the alpha series window.
Similarly, alpha series may be used to hold identifying information such as the names and addresses of individuals, social security and telephone numbers, or classifying labels such as “male” and “female”, or “high”, “medium”, and “low”.
Declaring an Alpha Series
To create a new alpha series, you may select Object/New Object... from the main EViews window or workfile button bar, and then click on Series Alpha and optionally enter a name to be given to your alpha series. If you provide a name, EViews will create a new alpha series object in the workfile. If you do not supply a name, EViews will open an UNTITLED alpha series window.
Alternatively, you may type the keyword “ALPHA”, followed by an optional series name, in the command window. The command:
alpha
will create a new untitled alpha series and will display the series in an object window. Likewise:
alpha myseries
will create a new alpha series MYSERIES. To open the alpha series windows for MYSERIES or SETSERIES, simply double-click on the corresponding alpha series icon in the workfile window directory, or enter the command “SHOW MYSERIES”.
In both of the cases described above, the alpha series will be initialized to contain missing values. For alpha series, the empty string (the null string, “”) is used to designate a missing value. If you are declaring an alpha series using a command, you may combine the declaration with the assignment of the values in the series. We explore alpha series assignment in “Assigning values to Alpha Series”.
For the most part, you need not worry about the lengths of string values in your alpha series since EViews will automatically resize your series as required, up to the limit specified in the global defaults. Beyond that point, EViews will truncate the values of the alpha series. To modify the truncation length, select Options/General Options... from the main menu and go to the Series and Alphas/Alpha truncation page. Enter the desired length, and subsequent alpha series creation and assignment will use the new truncation length.
You should bear in mind that the strings in EViews alpha series are of fixed length so that the size of each observation is equal to the length of the longest string. If you have a series with all short strings with the exception of one very long string, the memory taken up by the series will be the number of observations times the longest string. In settings of this sort, efficiency suggests that you consider using value maps ( “Value Maps”) to encode the values of the long string.
Editing an Alpha Series
There is no difference between editing an ordinary numeric series and editing an alpha series. Make certain that the alpha series is in edit mode by verifying the existence of the edit field in the series window. If not, click on the Edit +/– button to enable edit mode.
To edit a specific value, click on the desired cell. The existing value in the cell will appear in the edit window for you to modify or delete.
Simply type the new value in the edit window. Once you have entered the desired value, move to a new cell by clicking or using the arrow keys, or press the return key. This action will accept the entered value and prepare you for editing the newly selected cell.
Note that when editing the values of an alpha series, EViews does not require you to delimit your strings. You may simply type the relevant value in the edit field. EViews will remove any leading and trailing spaces from the value that you enter; if you wish to retain those characters, enclose your string in double quotes. To enter the double quote character as a part of your string, you should escape the character with another double quote so that you enter two consecutive double quotes.
Assigning values to Alpha Series
You may assign values to an alpha series using string expressions. An alpha series assignment has the form:
alpha_name = string_expr
where alpha_name is the name of an existing alpha series and string_expr is any expression containing a combination of string literals, alpha series, and functions or operators that return strings (see “Strings”for details). As with ordinary series, we may combine the declaration and assignment steps so that the commands:
alpha alpha_name = string_expr
or
genr alpha_name = string_expr
first create the alpha series alpha_name and then will assign the values using string_expr. In the latter command, EViews notes that the right-hand side expression is a string so that it knows to create an alpha series.
Alternatively, assuming that the alpha series exists, you may reassign the series values by clicking on Quick/Generate Series... in the main menu and entering the assignment and sample statements in the dialog. For example, if you enter the expression:
myalpha = string_expr
in the dialog, EViews will assign the values of the string_expr to the existing alpha series MYALPHA. Alternatively, you may enter the expression in the command line. In both cases, EViews will assign the corresponding values for all observations in the current workfile sample, overwriting the existing values.
Let us consider a simple example. Suppose that we have data on the company name (NAME), ticker symbol (SYMBOL), time of last trade (LAST_TIME), and closing price (LAST_TRADE) for each of the stocks in the Dow Jones Industrial Average on September 10, 2003.
Clicking on the icon for NAME, we can display the alpha series spreadsheet view. Note here that the default column width is not wide enough to display the contents of every observation, a condition that is signaled by the trailing “...” in the display for several of the observations. We may increase the column width by dragging the column header separators (the lines separating the column headers located just below the name of the series), by clicking on the Properties button and entering a larger number in the width field, or by double clicking on the column header separator to adjust the column width to the minimum width that displays all of the observation values without truncation.
Suppose now that we wish to create an alpha series containing the name of each company followed by its ticker symbol (enclosed in parentheses). A simple assignment statement generates the desired series:
alpha namesymb = name + " (" + symbol + ")"
EViews will create a new alpha series NAMESYMB if one doesn’t exist. Then, for every observation in the workfile sample, the contents of the alpha series NAME are concatenated with the literal strings for the parentheses, and the contents of the SYMBOL series.
Working with Alpha Series
Once created, an alpha series is used in two primary ways: (1) to generate numeric values and (2) to provide identifiers for the observations in the workfile.
Generating Numeric Values
By definition, an alpha series contains a string value for each observation. This means that if you use an alpha series in a setting requiring numeric input, all of the values of the alpha series will be treated as NAs. For example, if you attempt to compute the mean of the STATE alpha series or use the Dow company NAME in an equation regression specification, EViews will generate an error saying that there are an insufficient number of observations, since all of the numeric values are missing.
You may, however, use the string relational operators (see “String Relational Operators”) to generate a series of numeric values. For the data from our Dow Jones example, the commands:
smpl @all
series wname = (@lower(@left(NAME, 1)) = "w")
generate the numeric series WNAME containing the value 1 if the company name begins with the letter “W”, and 0 otherwise.
Similarly, the relational operators may be used when specifying a subsample. The command:
smpl @all if gender = "Male"
will restrict the workfile sample to include only observations where the string value in the alpha series GENDER is “Male”.
You may also use the various functions described in “String Information Functions”to generate numeric values.
Two examples are of particular importance. First, you may have an alpha series that contains string representations of numbers, such as “3.14159”. In order to use the strings as actual numbers, you must translate them into numbers, using either the string evaluation function @val.
Suppose, in our Dow Jones example, that we have the alpha series CHANGE containing information on the stock price change, expressed in both levels and percentages.
If we wish to extract only the levels information from the alpha series, the @left function may be used to extract the leftmost four characters of each string. The @val function may then be used to obtain the numeric value for each observation. Putting this together, the command:
series chgval = @val(@left(change, 4))
converts the leading four characters of the CHANGE series into numeric values, and places the results in the series CHGVAL.
Second, you may have an alpha series that contains a text representation of dates. Here, we have a series DATES that contains text representations of dates in “dd-Mon-YY” format (one or two-digit day, dash, three-character month abbreviation, dash, two-digit year). For example, “12-Jun-03” represents June 12, 2003.
To convert every element of this series into a numeric series containing date values, simply issue the command:
series dval = @dateval(dates)
The newly created series DVAL will contain date numbers associated with each of the string values in DATES.
Additional Issues
The Spreadsheet View
By default, the alpha series spreadsheet will display your data left-justified, with a column width of approximately 12 characters. You may change the justification and column width settings by clicking on the Properties button in the toolbar, then selecting a new justification setting and entering a new column width. Alternatively, the column width may be changed by dragging the separator in the column header to the desired position, or by double-clicking on the separator to adjust the column width to the minimum width that displays all of the observation values without truncation.
Auto-series
You should note that like ordinary series, you may also work directly with a series expression that produces an alpha series. For example, if ALPHA1 is an alpha series, the command:
show @lower(alpha1)
will result in an alpha series containing the contents of ALPHA1 with the text converted to all lowercase characters.
Auto-series expressions involving alpha series may also evaluate to ordinary series. For example, if NUMER1 is a numeric series and ALPHA1 is an alpha series, you may enter:
show numer1+@len(alpha1)+(alpha1>"cat")
to open a series window containing the results of the operation. Note that the parentheses around the relational comparison are required for correct parsing of the expression.