Book description
Cody's Collection of Popular SAS Programming Tasks and How to Tackle Them presents oftenused programming tasks that readers can either use as presented or modify to fit their own programs, all in one handy volume. Esteemed author and SAS expert Ron Cody covers such topics as character to numeric conversion, automatic detection of numeric errors, combining summary data with detail data, restructuring a data set, grouping values using several innovative methods, performing an operation on all character or all numeric variables in a SAS data set, and much more! SAS users of all levels interested in improving their programming skills will benefit from this easytofollow collection of tasks.
This book is part of the SAS Press program.
Table of contents
 Cover Page
 Title Page
 Copyright Page
 Contents
 List of Programs
 About this Book
 About the Author
 Acknowledgments

Chapter 1  Tasks Involving Conversion: Character to Numeric, Specific Values to Missing, and Changing Case
 Introduction
 Task: Converting character values to numeric values
 Task: Converting character values to numeric values using a macro
 Task: Converting a specific value such as 999 to a missing value for all numeric variables in a SAS data set
 Task: Converting a specific value such as 'NA' to a missing value for all character variables in a SAS data set
 Task: Changing all character values to either uppercase, lowercase, or proper case
 Task: Reading a numeric value that contains units such as Lbs. or Kgs. in the value
 Task: Solving part of the previous task using a Perl regular expression
 Conclusion
 Chapter 2  Grouping Data

Chapter 3  Summarizing Data
 Introduction
 Task: Using PROC MEANS to create a data set containing summary information
 Task: Computing the mean of a variable broken down by values of another variable: Using a BY variable
 Task: Computing the mean of a variable broken down by values of another variable: Using a CLASS statement
 Task: Have PROC MEANS name the variables in the output data set automatically (the AUTONAME option)
 Task: Creating multiple output data sets from PROC MEANS, each with a different combination of CLASS variables
 Task: Combining summary information (a single mean) with detail data: Using a conditional SET statement.
 Task: Combining summary information (a single mean) with detail data: Using PROC SQL
 Task: Combining summary information (a single mean) with detail data: Using PROC SQL without using PROC MEANS
 Task: Combining summary information (a single mean) with detail data: Using a macro variable
 Task: Combining summary data with detail data—for each category of a BY variable.
 Conclusion.

Chapter 4  Combining and Updating SAS Data Sets
 Introduction
 Task: Concatenating two SAS data sets—Using a SET statement
 Task: Concatenating two SAS data sets—Using PROC APPEND
 Task: Concatenating two SAS data sets with character variables of different lengths.
 Task: Concatenating two SAS data sets that contain character variables of different lengths and controlling the length of the character variables
 Task: Developing a macro to concatenate two SAS data sets that contain character variables of different lengths
 Task: Updating a SAS data set using a transaction data set
 Task: Using a MODIFY statement to update a master file from a transaction file
 Task: Updating several variables using a transaction file created with an INPUT method called named input
 Task: Matching names from two SAS data sets where the names may not be spelled the same (fuzzy merge)
 Conclusion
 Chapter 5  Creating Formats from SAS Data Sets

Chapter 6  Table Lookup Techniques
 Introduction
 Task: Performing a oneway table lookup using a MERGE statement
 Task: Performing a oneway table lookup using userdefined informats
 Task: Creating an INFORMAT using a control data set
 Task: Performing a oneway table lookup using a temporary array
 Task: Performing a twoway table lookup using a temporary array
 Conclusion

Chapter 7  Restructuring (Transposing) SAS Data Sets
 Introduction
 Task: Converting a data set with one observation per subject into one with multiple observations per subject (using a DATA step)
 Task: Converting a data set with one observation per subject into one with multiple observations per subject (using PROC TRANSPOSE)
 Task: Converting a data set with multiple observations per subject into one with one observation per subject (using a DATA step)
 Task: Converting a data set with multiple observations per subject into one with one observation per subject (using PROC TRANSPOSE)
 Conclusion
 Chapter 8  Tasks Involving Dates
 Chapter 9  Data Cleaning Tasks
 Chapter 10  Reading Data with UserDefined INFORMATS

Chapter 11  Tasks Involving Multiple Observations per Subject
 Introduction
 Task: Using PROC SORT to detect duplicate BY values or duplicate observations (records)
 Task: Extracting the first and last observation in a BY group
 Task: Detecting duplicate BY values using a DATA step
 Task: Identifying observations with exactly 'n' observations per subject
 Task: Computing differences between observations (for each subject)
 Task: Computing the difference between the first and last observation for each subject
 Conclusion

Chapter 12  Miscellaneous Tasks
 Introduction
 Task: Determining the number of observations in a SAS data set (using the NOBS= SET option)
 Task: Determining the number of observations in a SAS data set and assigning the value to a macro variable
 Task: Determining the number of observations in a SAS data set (using library tables)
 Task: Determining the number of observations in a SAS data set (using SAS functions)
 Task: Counting the number of a specific response in a list of variables
 Task: Computing a moving average
 Task: Presenting a macro to compute a moving average
 Task: Replacing the first eight digits of a credit card number asterisks
 Task: Sorting within an observation (using the ORDINAL function)
 Task: Sorting within an observation (using CALL SORTN)
 Task: Computing the average of the 'n' highest scores
 Task: Extracting the first and last name (and possibly a middle name) from a variable containing the first and last name (and possibly a middle name) in a single variable
 Index
 Accelerate Your SAS Knowledge with SAS Books
Product information
 Title: Cody's Collection of Popular SAS Programming Tasks and How to Tackle Them
 Author(s):
 Release date: September 2012
 Publisher(s): SAS Institute
 ISBN: 9781629597768
You might also like
book
HandsOn SAS for Data Analysis
Leverage the full potential of SAS to get unique, actionable insights from your data Key Features …
book
Python for Excel
While Excel remains ubiquitous in the business world, recent Microsoft feedback forums are full of requests …
book
Advanced SQL with SAS
This book introduces advanced techniques for using PROC SQL in SAS. If you are a SAS …
book
Learning SAS by Example
Learn to program SAS by example! Learning SAS by Example, A Programmer’s Guide, Second Edition, teaches …