Course sections

Introduction to SAS, Lecture 3

Concept of Permanent and Temporary Libraries

There are two types of libraries in SAS
• Temporary library
• Permanent library

Depending on the library name that is used when create a file, we can store SAS files temporarily or permanently.

Temporary Library
Its Temporary Storage Location of a SAS data file. They last only for the current SAS session. Work is the temporary library in SAS. When the session ends, the data files stored in the temporary library are automatically deleted.
The file is stored in Work, when:
• No specific library name is used while creating a file.
• Specify the library name as Work.

Data Orange;
set mylib.orangetree;
run;

Here the data set “Orange” will be stored in the temporary library “work”.

Permanent Library
It is the Permanent storage location of data files. Data sets stored in any Permanent SAS libraries are available for use in subsequent SAS sessions. A data set stored in a permanently library will be there unless we delete them physically. To store files permanently in a SAS data library specify a library name “Other” than the default library name “Work”.
Three Permanent Libraries provided by SAS are:
1. Local
2. SASUser
3. SASHelp

Creating a Permanent Library
To create a permanent library use libname statement. It creates a reference to the path where SAS files are stored. The LIBNAME statement is global, which means that the librefs remain in effect until modify them , cancel them, or end your SAS session. The LIBNAME statement assigns a permanent library for the current SAS session only. Assign a librefs to each permanent SAS data library each time a SAS session starts. SAS no longer has access to the files in the library, once the libref is deleted or SAS session is ended. Contents of Permanent library exists in the path specified.

Syntax for Creating a used defined Library linemen<libref‗path‗ ;
where,
• libref is the name of the library to be created. The following are some conventions that needs to be followed while creating the user defined library.
• A used defined library or any library for that matter in SAS can‘t have more than 8 characters.
• A libref can have both alpha base (A-Z) and Numeric base(0-9).
• It can start with an alphabet but not with any numbers.
• It can‘t have any of the special characters except “_‟ and it can begin with “_‟ and can continue with several combination of “_‟ .
• path is location in memory to store the SAS files.

Example of a used defined library:
Libname day1 “C:\Documents and Settings\admin\Desktop\Orange Tree”;
Here, Day 1 is a library reference name, libname is the keyword assigns the libref Day1 to the folder called OrangeTree in the specified path: ―C:\Documents and Settings\admin\Desktop\Orange Tree. Path should be specified in double quotes.

WhatsApp chat