SAS Base Programming Temporary vs Permanent SAS Data
SAS Base Programming Temporary vs. Permanent SAS Data Sets
SAS Data Library n When you invoke SAS, you automatically have access to temporary and a permanent SAS data library. work – temporary library sasuser – permanent library libref – permanent library You can create and access your own permanent libraries
Temporary SAS data set n By default, SAS data set you create is stored in the work library. n The SAS data set in the work library exists only during the current job or session, and automatically erased when you exit SAS. DATA distance; Miles = 26. 22; Kilomeers = 1. 61*Miles; PROC PRINT data = distance; RUN; PROC PRINT data = work. distance; RUN;
Assigning a libref n You can use the LIBNAME statement to assign a libref to a SAS data library. General form of the LIBNAME statement LIBNAME libref ‘SAS-data-library’ <options> Example Iibname mylib”\my. SASsummer 07data”;
Naming a libref n Rules for naming a libref n n n must be 8 characters or less must begin with a letter or underscore remaining characters are letters, numbers, or underscores. Example ____OK____not OK____ mylib_07 07_mylib _07 mylib#07 mylib 07
Two-level SAS filenames n Every SAS file has a two-level name libref. filename Second name (filename) refers to the file in the library First name (libref) refers to the library
Let’s try! * Create a Library named mylib; libname mylib 'C: Documents and Settingsxxxx'; * Permanent SAS Data Set; DATA mylib. distance; Miles = 26. 22; Kilometers = 1. 61*Miles; PROC PRINT data = mylib. distance; RUN; * direct reference; PROC PRINT data = 'C: Documents and Settingsxxxxdistance'; RUN;
Browsing a SAS data library n Use the _ALL_ keyword to list all the SAS files in the library and the NODS option to suppress the descriptor portions of the data sets. General form of the NODS option PROC CONTENTS DATA =libref. _ALL_ NODS; NODS must be used in conjunction with the keyword _ALL_
Browsing a SAS data set n To explore the description of a SAS data set, specify the data set name in the DATA=option PROC CONTENTS DATA =libref. SAS-data-set-name; Example PROC CONTENTS data = mylib. _all_ nods; RUN; PROC CONTENTS data = mylib. distance; RUN;
- Slides: 9