SAS Libraries – Why SAS library is used?

In SAS (Statistical Analysis System), files like SAS Datasets and SAS views are stored in a folder called SAS libraries. By default SAS system defines several SAS libraries for user such as SASuser, SASHelp, Webwork and Work.  SAS Library that are created by user are defined as User defined SAS libraries.

User defined libraries are of two types :

  1. Temporary libraries : These libraries are available until SAS job or Session.
  2. Permanent libraries : These type of libraries are available for any SAS session until the library get deleted by user.

Note : These two SAS libraries can be created in dependent mode and Independent mode.

  • Dependent mode : SAS files that can be shared with other libraries.
  • Independent mode : SAS file that can’t be shared with other libraries.

Creating SAS libraries.

SAS libraries can be created in two ways, using new library window and Libname Statement. SAS libraries can be divided (or) categorised into two types depending on Database, they are Dependent library and Independent library. Before creating user defined SAS library, we must note that the name for a library should not be more than 8 characters and name of a dataset, variable can be upto 16 characters. Make sure name should not start with a number.

  • Name should include numbers(0-9), Alphabets (A-Z) and underscore (_) .

When a Library in SAS is created, it means we indicating the location of our SAS library file to SAS software. If we delete a SAS library, the pointer (location of SAS files) will be deleted and SAS software no longer has access to the directory. But the content in the library will not be deleted and exits in out Operating system. Follow our simple steps for creating SAS libraries.

Creating using new library window

In the explore window, list of all active System defined libraries are available. Now select File > New as shown below.

ADVERTISEMENT
SAS libraries

In the new library window, type TKARTLIB in the name box and leaves the default engine selected. Select enable as startup so that the library is created each time you start SAS.

SAS library

Enter the path for a directory location to store SAS files by selecting Browse button.

Click on Ok button to assign the library and TkartLib appears in the active SAS libraries list.

Creating SAS library using Libname statement

This is the another type for creating SAS library using libname statement. To create navigate to Server files and Folder | New | SAS program and enter SAS statement as given below.

Libname prasanth '/folders/myfolders/tutorialkart.com';
Creating SAS library using Libname statement

As shown above, SAS library with name PRASANTH was successfully create and assigned to engine as shown above.

Engine stores data in different formats in dataset. In SAS, there are two types of Engines : Internal engine and External (or) Interface (or) access engines.

Conclusion :

In this SAS tutorial, we learnt that how SAS Libraries are used and how can we create them using new library window and using Libname statement. In our next SAS tutorial, will look about SAS basic concepts.