BookmarkSubscribeRSS Feed
psmith18
Calcite | Level 5

Can someone in a few sentences tell me what a SAS Library is, what it does, and why it's important?

I've watched the SAS Essentials Lesson 2 several times and I can't answer the above.

Thanks.

4 REPLIES 4
Reeza
Super User
If you're familiar with Schema's in DB that's a somewhat decent analogy.

In general though, it's also expanded over time to be a connection to specific file types, such as a DB, Excel file, JSON file or other formats that typically can have multiple data sets.

It's important because that's how you store permanent data sets in SAS, otherwise all are created in your WORK library which is essentially like volatile tables.

psmith18
Calcite | Level 5

I apologize I am not familiar with this DB individual. I don't know who that is.

So a SAS Library is a way to import and save files?

Thanks.

Reeza
Super User

DB is short for database.

 

Libraries can then be considered folders where you save and retrieve data from. 

That's probably the best analogy for you to understand. The WORK library is the default library, but is only temporary. Any data sets stored there are erased at the end of your session. Instead, for data you want to keep and reference or use again, you need to store it in a different folder location - so a different library.

 


@psmith18 wrote:

I apologize I am not familiar with this DB individual. I don't know who that is.

So a SAS Library is a way to import and save files?

Thanks.


 

ballardw
Super User

I SAS library, just like a physical library, is a storage place. It stores files mostly data sets but there are data views, and catalogs which are a somewhat complex topic because of the wide variety of things possible.

 

In one way you can think of it as a shorthand to your data. Instead of constantly typing a full path such as "d:\folder\subfolder\subsubfolder\projectfolder\datasetname.sasbdat" you only need to reference the library and the data set. If I have created a library named Project (warning: 8 character limit on library names) that pointed to that project folder then I use the syntax of Project.Datasetname to reference the data.

 

One thing that is very nice about SAS and facilitates moving from operating system to operating system is the Library. If you create library as above named project in a WINDOWS system and move over to a UNIX based system then you define your Project to point to the UNIX syntax file path such as "/mydrivemount/thisfolder/thatfolder/somefolder" and if the data sets are there, the same SAS syntax  Project.datasetname finds the data. Since you really only need to define the library one time in a session most of code, providing the dependent files you use, runs without having to change a lot of paths referencing the data.

 

This a bit of a simplification as a single Library can point to multiple folders.

 

Meaningful library names can even help remind you what the contents are. Suppose you do sports analysis. You might create separate libraries for Football (8 characters), BaseBall (8 characters), BsktBall, and Hockey. Then when you look at code that references something like Football.Players you might realize that data set contains data about players of Football. Which then doen't get confused with the Baseball.Players. Or Football.Teams.

 

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 774 views
  • 0 likes
  • 3 in conversation