/* SAS libraries --- One of the most confusing aspects of SAS is the concept of permanent and temporary SAS data sets. Temporary SAS data sets are created by SAS and are erased at the end of the SAS session. If you need to use the same data set, you must create it again. To avoid doing this repeatedly, you can assign a folder or directory to be a SAS library, and any SAS data set that is created and stored in this library will not be erased when you close out SAS. Let's run a simple DATA step from a previous program (after correcting any errors). */ data test; input x y z; datalines; 9 3 2 8 4 4 7 3 2 9 2 6 4 8 2 ; run; /* Note that the log calls the data set WORK.TEST but we only called it TEST. With a one-part name, SAS will assume it is a temporary data set, put it in the WORK library and call it WORK.TEST. Recall that anything in the WORK library will get erased when SAS closes. If we have done extensive programming in our DATA step, and have prepared the data for analysis, it is more efficient to save the data permanently, rather than run a very long, complicated DATA step every time. This will also result in shorter, easier to read programs when you create SAS programs to perform statistical analyses. All we need to do to make a SAS data set permanent is to define a SAS library (other than WORK) and use a two-part data set name when we create it. This is done with the LIBNAME statement. This statement essentially creates a "nickname" for a directory or folder to store our permanent SAS data sets in. We then use the "nickname" as the first part of a two-part SAS data set name Note: SAS does not care about the case of data set names, variables, etc. */ libname SASdata "Z:\"; data SASdata.test; input x y z; datalines; 9 3 2 8 4 4 7 3 2 9 2 6 4 8 2 ; run; /* Now the SAS log indicates that the data set is called SASDATA.TEST. If we look in the "Z:\" folder, we will find a file called test.sas7bdat. This is the same file that is called SASDATA.TEST in the SAS program. The extension "sas7bdat" indicates that this file is a SAS data set, but we will NEVER, NEVER, EVER use that extension in a SAS program. Now that the SAS data set has been created and permanently stored in a library, we can run another SAS program that can access that data set directly, without reading it in again. We can also use a different LIBNAME statement, since this statement merely defines a "nickname" for a folder. It doesn't matter what the "nickname" is as long as it points to the folder that contains the SAS data set. */ libname junk "Z:\"; proc print data=junk.test; title "Use of LIBNAME statement"; run;