Chapter 8. Manipulating Data from a Single Source

Example 8.1 Performing a Simple Subset 182

Example 8.2 Separating Unique Observations from Duplicate Observations Based on BY Values 185

Example 8.3 Separating Completely Duplicate Observations from Unique Observations 187

Example 8.4 Separating the First Observation in a BY Group from the Other Observations in the BY Group 190

Example 8.5 Accessing a Specific Number of Observations from the Beginning and End of a Data Set 193

Example 8.6 Creating a Customized Sort Order without Adding a New Column to the Table 196

Example 8.7 Adding New Observations to the End of a Data Set 199

Example 8.8 Adding Observations to a Data Set Based on the Value of a Variable 201

Example 8.9 Adding Observations to a SAS Data Set So the Values of a Variable Are Consecutive throughout the BY Group 203

Example 8.10 Adding Rows to a Table So That All Possible Values of Specific Columns Are Present in Each BY Group 208

Example 8.11 Expanding Single Observations into Multiple Observations 211

Example 8.12 Collapsing Observations within a BY Group into a Single Observation 215

Example 8.13 Obtaining the Previous Value of a Variable within a BY Group 220

Example 8.14 Comparing the Value of a Variable to Its Value in the Next Observation 225

Example 8.15 Applying the Same Operation to a Group of Variables 227

Example 8.16 Obtaining Hierarchical Data from a Table and Matching Them to the Rows in the Same Table 229

Example 8.17 Combining Generation Data Sets 232

The examples in this chapter work with a single data set or table. They show several techniques of rearranging the contents of your data set by using DATA step statements, SAS procedures, and PROC SQL features. The last example shows how to work with generation data sets.

The examples include techniques for transposing observations into variables and variables into observations, finding duplicate and unique observations in a data set, adding observations at specific locations to a data set, and obtaining variable values from preceding or succeeding observations.

Some of the examples are similar to ones already presented in that the program performs a merge or join, but in this chapter a single data set is merged or joined with itself.

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

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