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

Goal

Add observations to a data set to fill out each BY group so that the value of a specified variable consistently increments for every observation in the BY group.

Example 8.10 is similar to Example 8.9 except that the data are more complex in Example 8.10 and require different programming steps.

The example uses the same input data set as Example 8.12.

Example Features

Featured StepDATA step
Featured Step Options and StatementsBY-group processing, FIRST.variable and LAST.variable temporary variables, RETAIN statement
Related TechniquePROC MEANS, COMPLETETYPES, NOPRINT and NWAY options, ID and OUTPUT statements
A Closer Look ...

Get Combining and Modifying SAS® Data Sets: Examples Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.