From the course: SAS® 9.4 Cert Prep: Part 02 Accessing Data

Demo: Exploring automatic SAS libraries - SAS Tutorial

From the course: SAS® 9.4 Cert Prep: Part 02 Accessing Data

Demo: Exploring automatic SAS libraries

- Let's take a look at a program that creates data sets in different libraries and see what happens when SAS restarts behind the scenes. So in this program, we have a libname statement that's creating a libref named out and pointing to the output folder within our course data. Then we have a data step that's actually creating two new tables, one called class_copy1, and the other out.class_copy2. So I'll submit this program. And let's take a look at where those tables were actually saved. I'll go to libraries and expand the out library. Let's take a look at the code at the same time. So you'll notice in the out library, we have class_copy2 because we designated that it should be saved in the out library. Well, where did class_copy1 go? There is no library specified. Remember the default library is work. And there it is, class_copy1. So at this point, let's restart SAS. If I click the more applications options button and choose reset SAS session, SAS restarts behind the scenes. You'll notice SAS Studio even warns us that if we continue, then libraries and file shortcuts that we created will be deleted. I'll click yes. And my libraries view has been refreshed. So you'll notice I no longer see the out library. I also no longer see the PG1 library. Let's take a look at the work library. If I click it, there's now nothing in it. So remember the work library is temporary, so any tables that were saved in it are deleted when your SAS session ends. The out and PG1 libraries are also not available because those librefs were deleted when the session ended as well. But here's a question, is class_copy2, the table that was saved in the out library, still there? Is it still available? And the answer is yes, absolutely. The table is saved permanently. What has been deleted is simply the libref out. So what do I need to do to reestablish that out library? All I need to do is to resubmit that libname statement, the out library is now available and there is the permanent class_copy2 table we created. And what do we need to do to reestablish the PG1 library? I'll need to go back to the program that had the libname statement to create the PG1 library. I'll open the libname.sas program, resubmit the libname statement, and if I return to the library section, you can see the PG1 library is now available and all of our data files. So it's important to remember whenever you restart SAS, you need to run the libname.sas program to reestablish the PG1 library.

Contents