4. Working with Variables and Observations in SAS® Datasets

Introduction: Manipulating, Subsetting, Concatenating, and Merging Data58
Placement of Data Manipulation and Data Subsetting Statements59
 Immediately Following the INPUT Statement60
 Immediately after Creating a New Dataset61
 The INFILE Statement versus the DATALINES Statement62
Data Manipulation63
 Creating Duplicate Variables with New Variable Names63
 Duplicating Variables versus Renaming Variables64
 Creating New Variables from Existing Variables64
 Priority of Operators in Compound Expressions66
 Recoding Reversed Variables68
 Using IF-THEN Control Statements69
 Using ELSE Statements70
 Using the Conditional Statements AND and OR71
 Working with Character Variables72
 Using the IN Operator72
Data Subsetting74
 Using a Simple Subsetting Statement74
 Using Comparison Operators74
 Eliminating Observations with Missing Data for Some Variables75
A More Comprehensive Example79
Concatenating and Merging Datasets80
 Concatenating Datasets80
 Merging Datasets83
Conclusion87

Overview

This chapter shows how to modify a dataset so that existing variables are transformed or recoded so that new variables are created. The chapter shows how to eliminate unwanted observations from a dataset so that analyses are performed only on a specified subgroup or on participants that have no missing data. This chapter also shows the correct use of arithmetic operators, IF-THEN control statements, and comparison operators. Finally, the chapter shows how to concatenate and merge existing datasets to create new datasets.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.18.4