• Articles
  • Tutorials
  • Interview Questions

SAS File Concept

SAS Libraries

SAS files are stored in Libraries so SAS Library is a collection of SAS Files. SAS files are called SAS datasets. SAS Libraries have different implementation depending on our operating system. For example in Windows and UNIX environment, a library is typically a group of SAS files in same folder or directory.
Two types of libraries:

  • Temporary Library
  • Permanent Library

Temporary Library:

  • Its Temporary Storage Location of a data file
  • This lasts only for the current SAS Session
  • Work is the temporary library in SAS
  • When the session ends, the data files in the temporary library are deleted.
  • The file is stored in Work, when 1) No specific library name is used while creating file 2) Specifying library name as “Work”

Permanent Library:

  • As the name suggest, it is used for storing data files permanently.
  • Permanent SAS data libraries are stored until we delete them.
  • To store the files permanently in a SAS data library, specify library name other than Work.
  • Three default permanent Libraries provided by SAS are: Local , SASUser and SAShelp
  • SASHELP contains group of catalogs and other information to control SAS session
  • SASUSER contains personal settings

Referencing SAS Files:

To reference a SAS file two-level name is used:
Libref.filename
Libref – Name of the SAS data library
Filename – Name of the SAS file
.(Period) – Separate libref and filenames

Referencing Temporary SAS files:

Ex: Will consider filename as “SASFile1”.
Option1: Two-level name: Work.SASFile1
Work – It is the temporary SAS library
Option2: One-level name: SASFile1 (default it is stored in SAS library Work)

Referencing Permanent SAS files:

Before referencing permanent SAS files, we need to define them using LIBNAME Statement.

Certification in Bigdata Analytics

LIBNAME Statement:

LIBNAME libref ‘SAS-data-library’;

Libref: 1-8 characters long. Begin with letter or underscore. It contains only letters, numbers and underscores.
SAS-data-library: Physical location of the file. Specification of the file varies by operating system. Contents of    permanent library exist in the path specified.
Ex: libname policyDet ‘c:\INS\policy’;
Libname is global, which means libref remain in effect until we modify, cancel or end your SAS session.
LIBNAME assign the libref for current SAS session only, so each time we begin a SAS session, we must assign libref to each  permanent data library.

We have only one option to reference permanent SAS files:
Ex: Two-level-name:  policyDet.Autoinfo (Any library without Work)

More option on LIBNAME Statement:
LIBNAME libref CLEAR; — Disassociating one libref Ex: LIBNAME policyDet CLEAR
LIBNAME ALL CLEAR;  — Disassociating all assigned libref
LIBANAME libref (‘file1’ ‘file2’ ‘file3’); — Concatenating SAS Libraries by specifying the physical filename of each.

SAS files can be any of the following file types in addition to SAS datasets

  • SAS Catalog
  • Compiled SAS Program
  • SAS Utility file
  • Database files
  • Item store files.

Course Schedule

Name Date Details
Big Data Course 30 Nov 2024(Sat-Sun) Weekend Batch View Details
07 Dec 2024(Sat-Sun) Weekend Batch
14 Dec 2024(Sat-Sun) Weekend Batch

About the Author

Technical Research Analyst - Big Data Engineering

Abhijit is a Technical Research Analyst specialising in Big Data and Azure Data Engineering. He has 4+ years of experience in the Big data domain and provides consultancy services to several Fortune 500 companies. His expertise includes breaking down highly technical concepts into easy-to-understand content.