Previous Page | Next Page

Modifying SAS Data Set Names and Variable Attributes

Renaming SAS Data Sets

Renaming data sets is often required for effective library management. For example, you might rename a data set when you archive it or when you add new data values.

Use the CHANGE statement in the DATASETS procedure to rename one or more data sets in the same library. Here is the syntax for the CHANGE statement:

CHANGE old-name=new-name;

where

old-name

is the current name of the SAS data set.

new-name

is the name that you want to give the data set.

This example renames two data sets in the SAS data library USCLIM, which contains information about the climate of the United States. The following program starts the DATASETS procedure, then changes the name of the data set HIGHTEMP to USHIGH and the name of the data set LOWTEMP to USLOW:

options pagesize=60 linesize=80 nonumber nodate;
libname usclim 'SAS-data-library';

proc datasets library=usclim;
   change hightemp=ushigh lowtemp=uslow;
run;

As it processes these statements, SAS sends messages to the SAS log, as shown in the following output. The messages verify that the data sets are renamed.

Renaming Data Sets in the Library USCLIM

7    options pagesize=60 linesize=80 nonumber nodate;
8    libname usclim 'SAS-data-library';
NOTE: Libref USCLIM was successfully assigned as follows: 
      Engine:        V8 
      Physical Name: external-file
9    
10   proc datasets library=usclim;
                              -----Directory-----

                   Libref:            USCLIM                
                   Engine:            V8                    
                   Physical Name:     external-file
                   File Name:         external-file
                   Inode Number:      1864992               
                   Access Permission: rwxr-xr-x             
                   Owner Name:        userid                
                   File Size (bytes): 4096                  


                                        File
               #  Name       Memtype    Size  Last Modified
               --------------------------------------------------
               1  BASETEMP   CATALOG   20480   15NOV2000:14:38:35
               2  HIGHTEMP   DATA      16384   15NOV2000:14:26:48
               3  HURRICANE  DATA      16384   15NOV2000:14:29:11
               4  LOWTEMP    DATA      16384   15NOV2000:14:30:08
               5  REPORT     CATALOG   20480   15NOV2000:14:39:02
               6  TEMPCHNG   DATA      16384   15NOV2000:14:30:41
11      change hightemp=ushigh lowtemp=uslow;
12   run;
NOTE: Changing the name USCLIM.HIGHTEMP to USCLIM.USHIGH (memtype=DATA).
NOTE: Changing the name USCLIM.LOWTEMP to USCLIM.USLOW (memtype=DATA).

Previous Page | Next Page | Top of Page