Back to Political Science


Finding Data


Getting Accounts


SAS Questions


SPSS Questions

SAS system files

Creating Permanent SAS Files

Specifying the data in this way can be tedious, and not just for you, the user. While you're waiting for SAS to go through what could be very long input statements (imagine the input statement from the cumulative version of the NES, for example, which boasts hundreds of variables), the computer is grinding away, using lots of memory and swap space to write the data set that you've specified. Once SAS is done, it deletes these file; hence, they're often called temporary or work data files.

Often, you'll find that you need to run many different programs on the same data over the course of a single reserach program, but that the recodes and other computations will be the same or virtually the same for all the programs you need to run.

With each data step you perform, SAS creates a temporary work data file; at the end of your job, this file is deleted. Often it's easier to create a permanent data set, or SAS system file. This is a file that stays on the computer after the job ends and that contains both your data, all the information SAS needs to read them, and any additional calculations you had performed and saved in the dataset. Moreover, since SAS doesn't have to run through all those data steps, using permanent data sets is more efficient in terms of your time, SAS's time, and your computer's resources.

If you want to create a SAS system file, you must first tell SAS where it should save the data. You do this by specifying a library name with the LIBNAME statement:

LIBNAME libref 'location';

where libref is the name you assign to the library and 'location' is the directory in which SAS will store the file.

Your data statement will now take the following form:

DATA libref.dataname;

This tells SAS to write the file dataname to the library libref.

Reading SAS System Files

You may use permanent data sets in your programs in any place where you would usually define a temporary dataset. Remember, though, that you must always have told SAS which data library you're referring to with a LIBNAME statement somewhere within (usually at the beginning) your program. You may wish to perform additional calculations on the data, in which case you would specify the file within a DATA step:

DATA libref.dataname;

If you don't need to do any additional calculations, however, you can simply specify the name of the system file within each procedure statement you perform. For example,

PROC FREQ data=libref.dataname;
PROC REG data=libref.dataname;

One problem with SAS system files is that unlike raw data, which are generally kept in ascii format, the system file is a binary program that is platform-specific. That is, if you create a system file on a Unix-based machine, you can't use it on a Win NT machine without converting it (in much the same way that Word Perfect for Windows must convert a file created in WP for DOS). To do this, you have to create a portable file