Book contents
- Frontmatter
- Contents
- Acknowledgments
- About This Book
- How to Use This Book
- Chapter 1 Navigation
- Chapter 2 Preliminary Data Exploration
- Chapter 3 Storing and Manipulating Data
- Chapter 4 Advanced Concepts in Dataset and Variable Manipulation
- Chapter 5 Introduction to Common Procedures
- Chapter 6 Procedures for Simple Statistics
- Chapter 7 More about Common Procedures
- Chapter 8 Data Visualization
- Chapter 9 JMP as an Alternative
- Index
Chapter 3 - Storing and Manipulating Data
Published online by Cambridge University Press: 05 June 2016
- Frontmatter
- Contents
- Acknowledgments
- About This Book
- How to Use This Book
- Chapter 1 Navigation
- Chapter 2 Preliminary Data Exploration
- Chapter 3 Storing and Manipulating Data
- Chapter 4 Advanced Concepts in Dataset and Variable Manipulation
- Chapter 5 Introduction to Common Procedures
- Chapter 6 Procedures for Simple Statistics
- Chapter 7 More about Common Procedures
- Chapter 8 Data Visualization
- Chapter 9 JMP as an Alternative
- Index
Summary
In this chapter we will learn about storing and manipulating data in SAS, by considering the structure of datasets and the characteristics of variables. We begin with a description of how to access existing data using the SAS specific library convention, including an overview of the different types of storage SAS offers. The Data step is introduced as the primary method for data manipulation in SAS, punctuated with plenty of sample syntax and illustrative figures providing the user with a thorough understanding of what the Data step can do for a programmer. We then move to variable creation and manipulation including an overview of functions and different ways to transform numeric and character variables.
LIBRARIES, LIBRARY REFERENCES, AND THE LIBNAME STATEMENT
SAS stores and creates data using a library convention. Libraries are a way to call upon a location within the computer by labeling it with a single letter or phrase for the duration of the SAS session. This allows the user a time-saving alternative to repeating a lengthy path name in multiple places. When pulling data from a shared server, the path can include several folders to navigate through before locating the file, for example ‘Z:\JK\SAS 2014\Paper2019\Datasets\final’.
Example 3.1, a LIBNAME statement allows the programmer to write the path once, assigning it the library reference (libref) ‘x.’ This libref can be used to locate any SAS dataset in that particular folder for the entirety of the SAS session. Library References can consist of one to eight characters and must begin with a letter, a through z, or an underscore (_); remaining characters may consist of letters, numbers, or underscores.
EXAMPLE 3.1. LIBNAME Statement Syntax.
libname x ‘Z:\JK\SAS 2014\Paper2019\Datasets\final’;
One way to view a dataset within an active library is to toggle to the explorer tab and click on the ‘Libraries’ folder (Figure 3.1). SAS will always show three active libraries, ‘Sashelp’, ‘Sasuser’, and ‘Work.’ The library ‘X’ was created in Example 3.1 using a libname statement. While the libref ‘X’ is a temporary shortcut for accessing a specific location, any dataset written to that location using the libref is stored there permanently.
By double-clicking on the desired folder we are able to view its contents. When we open a library in the Explorer window, SAS automatically displays all SAS version 8 or higher datasets stored in that location.
- Type
- Chapter
- Information
- Data Management Essentials Using SAS and JMP , pp. 29 - 53Publisher: Cambridge University PressPrint publication year: 2016