Using a Variety of Advanced Functions

The LAG Function

A Brief Overview

Suppose you have the Certadv.Stock6Mon data set that contains opening and closing stock prices for the past six months for two different companies. You are trying to determine which company has the bigger difference in the daily opening price between consecutive days.
To start, consider what you want the LAG function to return, as shown below.
Figure 14.1 Desired LAG Function Results for ABC Company, by Day
Result to include three new variables FirstPrevDay, SecondPrevDay, and ThirdPrevDay.
The LAG function enables you to compare the daily opening prices between consecutive days by retrieving the previous values of a column from the last time that ...

Get SAS Certified Professional Prep Guide now with O’Reilly online learning.

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