SAS Libname

SAS Day 7: Libname

The other day, the data team asked me if I can convert an Excel file to SAS dataset and store it in the data folder. I end up not knowing how to save the converted SAS dataset. Thanks very much to June, now I know Iibname is not only for reading data, but it can also be used to store datasets!

Libname consist of:

  • the keyword LIBNAME.
  • the name that you want to use.
  • the pathname that represents the physical location of the library.
  • a semicolon.
  1. Assign the name to the location we can fetch the data from.
  2. Assign the name to the location we can store our data in.


libname adam ‘C:\Users\fangy\Desktop\All\3study’ access = readonly;


Pexels / Pixabay


  1. Fetch Data

We can use set statement to read in any dataset we want.
Example: we want ADSL.

data adsl;
set adam.adsl;

2. Store Data

We can use set statement to store any dataset in the location assigned to libname.
Example: we want to store final into adam library.

data adam.qcadsl;
set final;

Happy SAS Coding 🦀




Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Social media & sharing icons powered by UltimatelySocial
%d bloggers like this: