Friday, 23 December 2016

SAS Libraries



SAS Libraries 


1) Every SAS file is stored in a SAS library.

2) SAS Library is a collection of SAS files.

3) A SAS data library is the highest level of organization for information within SAS.

4) In the Windows and UNIX environments, a library is typically a group of SAS files in the same folder or directory.



Temporary Library:
 Its Temporary Storage Location of a data file
 They last only for the current SAS session
 Work is the temporary library in SAS
 When the session ends, the data files in the
temporary library are deleted
 The file is stored in Work, when:

 No specific library name is used while

creating a file

 Specify the library name as Work

Permanent Library:
 It’s the Permanent storage location of data files
 Permanent SAS libraries are available in
subsequent SAS sessions
 Permanent SAS data libraries are stored until delete
them
 To store files permanently in a SAS data library:
 Specify a library name Other than the
default library name Work
 Three Permanent Libraries provided by SAS are:
 Local
 SASuser
 SAShelp
 
 
Creating a Permanent Library:
 To create a permanent library use libname statement
 It creates a reference to the path where SAS files are stored
 The LIBNAME statement is global, which means that the librefs remain in effect until modify
them , cancel them, or end your SAS session
 The LIBNAME statement assigns the libref for the current SAS session only
 Assign a libref to each permanent SAS data library each time a SAS session starts
 SAS no longer has access to the files in the library, once the libref is deleted or SAS session is
ended.
 Contents of Permanent library exists in the path specified
Syntax :
libname <libref> ‘<path>‘ ;
where,
 libref is the name of the library to be created
 It can be 1 to 8 characters long
 Begins with a letter or underscore
 Contains only letters, numbers, or underscores
 path is location in memory to store the SAS files
 
 Example:
libname Taxes ‘C:\Documents and Settings\admin\Desktop\Training‘ ;
Here,
 Taxes - A library reference name
 libname - This keyword assigns the libref taxes to the folder called
training in the path:
‘C:\Documents and Settings\admin\Desktop\Training‘
 Path should be specified in single code
Data lib1.emp;
Length name$ 12;
Input id name$ doj sal;
Informat doj mmddyy8. sal dollar7.;
Format doj date9. sal dollar7.;
Label id = “Employee Id” name = “Employee Name” doj = “Date of Joining”
Sal = “Salary”;
Cards;
1076 abcasdayut 12/23/05 $10,000
1983 aaaertgr 07/12/98 $40,000
1723 xyzasdsf 04/15/98 $25,000
;
Run;

No comments:

Post a Comment