Resources

SAS Studio: Help Center


How do I create my own SAS library?

bullet icon Show instructions for creating a SAS library with: SAS code | SAS Studio user interface
To create a new SAS library with SAS code, you use the LIBNAME statement. The LIBNAME statement associates the name of the library, or libref, with the physical location of the library.

There are a few guidelines to keep in mind when you create the name of your library.

Library names

  • are limited to eight characters.
  • must begin with a letter or underscore.
  • can contain only letters, numbers, or underscores. Blanks are not allowed.
You need to submit a LIBNAME statement only once during a SAS session. The libref remains in effect for the duration of the session.

A LIBNAME statement consists of

  • the keyword LIBNAME.
  • the libref name that you want to use.
  • the pathname that represents the physical location of the library.
  • a semicolon.

The following LIBNAME statement assigns the mypublic libref to your Public folder. The directory that you associate with the libref must already exist before you can assign it to the libref.

libname mypublic '/public/';

You can submit the LIBNAME statement alone, or you can add it to the top of your program so that it is run every time you run the program.

You can create a new SAS library by using the New Library window in SAS Studio.

  1. Open the Libraries section of the navigation pane in SAS Studio. Then click New library button.

  2. In the Name box, enter the libref for the library. Library names are limited to eight characters, must begin with a letter or underscore, and can contain only letters, numbers, or underscores. Blanks are not allowed.

  3. In the Path box, enter the physical path where the library resides.

  4. If you want to access this library each time you use SAS Studio, select Re-create this library at start-up.

    The following image shows how to assign the mypublic libref to your public folder. The directory that you associate with the libref must already exist before you can assign it to the libref.

    New Libary window showing options to create a library