Assigning a read password ('Read password') to a data set.
Specifying how data is sorted.
Creating a composite index ('VITAL') on the BIRTH and SALARY variables for the 'group' data set, with options to exclude observations with missing values (NOMISS) and ensure uniqueness (UNIQUE).
Assigning formats and informats to variables.
Renaming variables in a data set (e.g., 'oxygen' to 'intake').
Assigning labels to variables.
Data Analysis
Type : SAS_LIBRARY
The examples use data sets stored in a SAS library ('health') which must be defined (LIBNAME).
1 Code Block
OPTIONS, LIBNAME
Explanation : Sets system options for the SAS log (page size, line size, date suppression, starting page number, source code display) and assigns the libname 'health' to a SAS library.
Copied!
options pagesize=40 linesize=80 nodate pageno=1 source;
LIBNAME health 'SAS-library';
1
options pagesize=40 linesize=80 nodate pageno=1
2
SOURCE;
3
LIBNAME health 'SAS-library';
4
2 Code Block
PROC DATASETS
Explanation : Starts the DATASETS procedure, specifying 'health' as the input library and suppressing the display of the directory list (NOLIST).
Copied!
proc datasets library=health nolist;
1
PROC DATASETS library=health nolist;
3 Code Block
MODIFY (DATASETS)
Explanation : Modifies the 'group' data set: assigns the label 'Test Subjects', sets 'green' as the read password, and specifies 'lname' as the sorting variable.
Copied!
modify group (label='Test Subjects' read=green sortedby=lname);
1
modify group (label='Test Subjects' read=green sortedby=lname);
2
4 Code Block
INDEX CREATE (DATASETS)
Explanation : Creates a composite index named 'vital' on the 'birth' and 'salary' variables. The NOMISS option excludes observations with missing values. The UNIQUE option ensures that each combination of values is unique.
Copied!
index create vital=(birth salary) / nomiss unique;
1
index create vital=(birth salary) / nomiss unique;
2
5 Code Block
INFORMAT, FORMAT, LABEL (DATASETS)
Explanation : Applies the 'date7.' informat and format to the 'birth' variable. Assigns the label 'current salary excluding bonus' to the 'salary' variable.
Explanation : Modifies the 'oxygen' data set: renames the variable 'oxygen' to 'intake' and assigns the label 'Intake Measurement' to the new variable. The QUIT statement terminates the DATASETS procedure.
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.