Chapter Contents
Chapter Contents
The DATASOURCE Procedure

Renaming Time Series Variables

Sometimes the time series variable names as given by data vendors are not descriptive enough, or you may prefer a different naming convention. In such cases, you can use the RENAME statement to assign more meaningful names to time series variables. You can also use LABEL statements to associate descriptive labels with your series variables.

For example, the series names for effective exchange rate (F_X_AM) and exchange rate index (F_X_AH) used by IMF can be given more descriptive names and labels by the following statements:

   filename ifsfile 'host-specific-file-name' <host-options>;
   proc datasource filetype=imfifsp infile=ifsfile interval=month
                   out=exchange outcont=exchvars;
      where country in ('112','146','158') and partner=' ';
      keep  f_x_ah f_x_am;
      range from '01jun87'd to '01feb88'd;
      rename  f_x_ah=exrindex  f_x_am=effexr;
      label   f_x_ah='F_X_AH: Exchange Rate Index 1985=100'
              f_x_am='F_X_AM: Effective Exchange Rate(MERM)';
   title1 'Printout of OUTCONT= Showing New NAMEs and LABELs';
   proc print data=exchvars noobs;
      var  name label length;
   title1 'Contents of OUT= Showing New NAMEs and LABELs';
   proc contents data=exchange;

The RENAME statement allows input names to be quoted strings. If the name of a series in the input file contains blanks or special characters that are not valid SAS name syntax, use the SAS option VALIDVARNAME= ANY or put the series name in quotes to rename it. See the FAME example using rename in the "Selecting Time Series Variables -- The KEEP and DROP Statements" section.

Printout of OUTCONT= Showing New NAMEs and LABELs

name label length
EFFEXR F_X_AM: Effective Exchange Rate(MERM) 5
EXRINDEX F_X_AH: Exchange Rate Index 1985=100 5

Contents of OUT= Showing New NAMEs and LABELs

The CONTENTS Procedure

Data Set Name: WORK.EXCHANGE Observations: 27
Member Type: DATA Variables: 7
Engine: V7 Indexes: 0
Created: 0:28 Monday, June 1, 1998 Observation Length: 24
Last Modified: 0:28 Monday, June 1, 1998 Deleted Observations: 0
Protection:   Compressed: NO
Data Set Type:   Sorted: NO

-----Engine/Host Dependent Information-----
Data Set Page Size: 8192
Number of Data Set Pages: 1
First Data Page: 1
Max Obs per Page: 338
Obs in First Data Page: 27
Number of Data Set Repairs: 0
File Name: /tmp/SAS_workAFBC000027F8/exchange.sas7bdat
Release Created: 7.00.00P
Host Created: HP-UX
Inode Number: 14442
Access Permission: rw-r--r--
Owner Name: sasknh
File Size (bytes): 16384

-----Alphabetic List of Variables and Attributes-----
# Variable Type Len Pos Format Label
3 country Char 3 4   COUNTRY CODE
4 csc Char 1 7   CONTROL SOURCE CODE
7 date Num 4 0 MONYY7. Date of Observation
2 effexr Num 5 17   F_X_AM: Effective Exchange Rate(MERM)
1 exrindex Num 5 12   F_X_AH: Exchange Rate Index 1985=100
5 partner Char 3 8   PARTNER COUNTRY CODE
6 version Char 1 11   VERSION CODE

Figure 10.6: Renaming and Labeling Variables

Notice that even though you changed the names of F_X_AH and F_X_AM to EXRINDEX and EFFEXR, respectively, you still used their old names in the KEEP and LABEL statements because renaming takes place at the output stage.

Chapter Contents
Chapter Contents

Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.