Before learning to write more SAS programs, let’s learn about SAS libraries and how to reference SAS files that are stored in libraries. File referencing is an initial point in any SAS program as it tells SAS the exact location of the data set to be edited, stored or analyzed.
1. Sashelp – is a permanent library and contains sample files or data sets.
2. Sasuser – is a permanent library and can store personal files.
3. Work – is a temporary library and stores files only for current session.
Referencing SAS files – Two-Level Names : To reference permanent SAS data sets, two-level names are used. One-level names are used only for temporary files i.e. files stored in Work library.
libref.filename , where libref = name of the SAS Library in which the file is stored and filename = name of the SAS file
For example, if we are refering to SAS data set called Cars which is located in Sashelp library, we can write sashelp.cars
Storing SAS files or data sets :
1. To store file permanently – define a two level name to refer the file (where libref is other than Work)
2. To store file temporarily – define a one level name(only the filename) or two level name as Work.filename
3. Follow rules for SAS data set names :
i. 1 to 32 characters
ii. must begin with an alphabet A-Z(uppercase or lowercase) or underscore
ii. can continue with any combination of alphabets, numbers or underscores
We have few more steps before we learn to analyze data sets.
Note : i. Referencing an important part of learning SAS as it defines whether the files are being stored temporarily or permanently. ii. This blog relates only to Windows, OpenVMS and UNIX based systems.