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 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.