Saving Data in SAS

SAS data files contain both data and information about the data, such as variable and value labels. SAS data files are stored in a special format that is written to and read by the SAS System. It is generally more efficient for SAS to read a SAS data file than to read a raw data file or a file store in some other non-SAS format.

SAS files are saved with special extensions which are used to indicate their file types. The most common type of SAS file, a SAS data file, is saved on UNIX with the extension ".ssd01."

The LIBNAME statement is used to save SAS data files for later processing. Here is the basic format of the LIBNAME statement:

LIBNAME libref 'UNIX_directory';

where LIBNAME is a keyword, libref is a library reference, and UNIX_directory is the name of a UNIX directory where the SAS data file is saved or will be saved.

* The libref is used to associate the UNIX_directory with the file that will be read from or written to that directory.
* The directory name must be enclosed in quotes. The directory must already exist. UNIX file and directory names are case-sensitive: "mydir" is not the same as "MYDIR" which is not the same as "Mydir."

In the following program a SAS data file named "first.ssd01" will be created in the current working directory.

LIBNAME saveme '.';
data saveme.first;
infile 'raw.data';
input var1 var2 var3;

The LIBNAME assigns the "saveme" libref to the current working directory, represented by a period ('.'). The DATA statement associates the libref with the name of the file that is being created, "first." This file will be saved in the current working directory.

Page tags: data sas
page_revision: 0, last_edited: 1193768731|%e %b %Y, %H:%M %Z (%O ago)
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License