SAS Libraries
SAS Data files/sets are stored in SAS library
Types of SAS libraries:
There are two types of SAS libraries,
(1) Permanent library,
SASUser and SASHelp are inbuilt permanent libraries of SAS. We can create a new SAS
library by using SAS utilities or by writing the codes in the editor window. These libraries are
named as permanent because if we create a program in SAS and save it in these permanent
libraries then these will be available as long as we want them.
(2) Temporary library,
Work is the inbuilt temporary library of SAS. All the programs that we create are stored in
this work library if we do not assign any other library to them. You can check this work library in
the Explore Window. If you create a SAS program and have not assign any permanent library to it
then if you end the session after that again you start the software then this program will not be in
the work library. Because it will only be there in Work library as long as the session goes ones.
Creating the libraries:
We can create libraries by using either ‘libname’ statement or SAS utilities
The format of the LIBNAME statement is:
Syntax: LIBNAME libref 'File path name here';
Rules For creating SAS library names:
Must be 8 characters or less
Must begin with a letter or underscore
Must contain only letters, numbers or underscores, no special characters including blank
spaces
Naming:
Two level naming
To store SAS datasets in any created temporary or permanent library, we have to give
library name before the dataset name. Library name and dataset name should be separated by ‘.’
This is Two level naming
One level naming
You can omit the libname, and give only dataset name, then it is one-level naming
Rules for creating SAS dataset names and Variable names
:
We can also simply call as Rules for creating SAS names
• Names must be 32 characters long or less
• Can be uppercase, lowercase or mixed-case i.e., not case-sensitive
• Must start with a letter or underscore. Subsequent characters can be letters,
underscores, or numeric digits
• No special characters like $, #, %, &, * etc., including blank spaces
Example Valid names: _name, my_name, zip5, U_and_mE
Invalid names: -name, my-name, 5 zips, per%, u&me, my@w
SAS programs Layout:
•
Every SAS statement should end with semicolon;
• SAS statements can be in lowercase, uppercase or mixed case
• We can write multiple SAS statements in single line
• Also, they can start from any position in a line
Comments:
We can insert comment lines in our SAS programs
There are two ways to do this
(1) start with * put text and then end with;
(2) Start and end with /* and put text in middle... short cut to do this is ctrl+/
SAS Data values/ Variable values/ Data types:
Two data types are there,
(1) Character -Character values default length is 8 bytes and can be
increased up to 32,767 bytes by using LENGTH statement
1byte = 1 character.
contains any value like letters, numbers, special characters and blanks.
$ followed by variable name indicates it as a character variable
(2) Numeric – Get stores as normal numeric value till 12 digits and after that get stored in
electronic format. Contains only numbers
Standard numeric data values
Recall that standard numeric data values can contain only:
• Numbers
• decimal points
• numbers using scientific (E) notation
• negative (minus) and positive (plus) signs
Examples of standard numeric values include:
26, 3.9, -13, +3.14, 314E-2, and 2.193E3.
Nonstandard numeric data values
On the other hand, nonstandard numeric data values include:
• values that contain special characters, such as dollar signs ($),
commas (,)
• date and time values
• data in fraction, integer binary, real binary, and hexadecimal forms
Examples of nonstandard numeric values include:
$1.26, 23:12:45 and 03/07/47.
Информация по комментариям в разработке