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


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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.