O'Reilly logo

Combining and Modifying SAS® Data Sets: Examples Second Edition by Michele M. Burlew

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

Goal

Within the same data set, look ahead from a variable value in one observation to return the value of the same variable in the observation that immediately follows it. Then compare the returned value with the current observation or use it in a calculation on the current observation.

This example uses the same input data set as Example 8.13.

Example Features

Featured StepDATA step
Featured Step Options and StatementsMERGE statement, FIRSTOBS= data set option

Input Data Set

Data set PRODUCTION records the number of units of an item made on several days at four plant locations.

                 PRODUCTION

                                     units_
Obs      plant         proddate       made 1 Aux Plant 03/02/2009 76 2 Main Plant ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required