Combining and Modifying SAS(R) Data Sets: Examples Combining Single Observations with Single Observations * Example 2.1 Merging Data Sets by a Common Variable, Specifying Their Origin, and Replacing Missing Values * Example 2.2 Combining Observations When Variable Values Do Not Match Exactly * Example 2.3 Combining Observations When There Is No Common Variable * Example 2.4 Performing a Table Lookup When the Lookup Data Set is Indexed * Example 2.5 Performing a Table Lookup When the Lookup Data Set is Not Indexed * Example 2.6 Matching Observations Randomly * Example 2.7 Combining Observations Based on a Calculation on Variables Contributed by Two Data Sets Combining a Single Observation with Multiple Observations * Example 3.1 Adding Values to All Observations in a Data Set * Example 3.2 Adding Values from the Last Observation in a Data Set to All Observations in Another Data Set * Example 3.3 Merging Observations from Multiple Data Sets Based on a Common Variable * Example 3.4 Applying Transactions to a Master Data Set Based on a Common Variable * Example 3.5 Combining and Collapsing Observations Based on a Common Variable * Example 3.6 Applying Transactions to a Master Data Set Using an Index * Example 3.7 Removing Observations from a Master Data Set Based on Values in a Transaction Data Set * Example 3.8 Performing a Table Lookup with a Small Lookup Data Set * Example 3.9 Performing a Table Lookup with Large Nonindexed Data Sets * Example 3.10 Performing a Table Lookup Using a Composite Index When the Transaction Data Set Contains Duplicate Values * Example 3.11 Performing a Table Lookup with a Large Lookup Data Set That Is Indexed Combining Multiple Observations with Multiple Observations * Example 4.1 Adding Variables from a Transaction Data Set to a Master Data Set * Example 4.2 Updating a Master Data Set with Only Nonmissing Values from a Transaction Data Set * Example 4.3 Generating Every Combination of Observations (Cartesian Product) between Data Sets * Example 4.4 Generating Every Combination of Observations between Data Sets Based on a Common Variable * Example 4.5 Delaying Final Disposition of Observations Until All Processing Is Complete * Example 4.6 Generating Every Combination between Data Sets, Based on a Common Variable When an Index Is Available * Example 4.7 Combining Multiple Data Sets without a Variable Common to All the Data Sets * Example 4.8 Interleaving Nonsorted Data Sets * Example 4.9 Interleaving Data Sets Based on a Common Variable * Example 4.10 Comparing All Observations with the Same BY Values Manipulating Data From a Single Source * Example 5.1 Performing a Simple Subset * Example 5.2 Separating Unique Observations from Duplicate Observations * Example 5.3 Accessing a Specific Number of Observations from the Beginning and End of a Data Set * Example 5.4 Adding New Observations to the End of a Data Set * Example 5.5 Adding Observations to a Data Set Based on the Value of a Variable * Example 5.6 Simulating the LEAD Function by Comparing the Value of a Variable to Its Value in the Next Observation * Example 5.7 Obtaining the Lag (Previous Value) of a Variable within a BY Group * Example 5.8 Applying Common Operations to a Group of Variables * Example 5.9 Calculating Totals across a BY Group to Produce Either a Grand or Cumulative Total * Example 5.10 Calculating the Percentage That One Observation Contributes to the Total of a BY Group * Example 5.11 Adding a New Variable that Contains the Frequency of a BY-Group Value * Example 5.12 Subsetting a Data Set Based on the Calculated Average of a BY Group * Example 5.13 Really Rounding Numbers * Example 5.14 Collapsing Observations within a BY Group into a Single Observation * Example 5.15 Expanding Single Observations into Multiple Observations * Example 5.16 Reshaping Observations into Multiple Variables Utilities and Functions * Example 6.1 Converting Variable Types from Character to Numeric and Vice Versa * Example 6.2 Determining the Type of a Variable's Content * Example 6.3 Determining Whether a Variable is Character or Numeric * Example 6.4 Creating a SAS Data Set Whose Variables Contain the Attributes of Variables from Another SAS Data Set * Example 6.5 Sorting Variable Values within an Observation (Bubble Sort) * Example 6.6 Creating Equal-Sized Random Samples and Producing Equal-Sized Subsets or Exact-Sized Subsets * Example 6.7 Counting the Occurrences of a String within the Values of a Variable * Example 6.8 Extracting a Character String without Breaking the Text in the Middle of a Word * Example 6.9 Creating SAS Datetime Values * Example 6.10 Creating a SAS Time Value from a Character Value * Example 6.11 Calculating a Person's Age Appendix Error Checking When Using MODIFY or SET with KEY= * Example 1: Routing Execution When an Unexpected Condition Occurs * Example 2: Using Error Checking on All Statements That Use KEY=