O'Reilly logo

Longitudinal Data and SAS by EdD Ron Cody

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

2   The LAG and DIF Functions

Introduction

Using the LAG Function to Compute Differences

Demonstrating Some Related Functions: LAG2, LAG3, and So Forth

Demonstrating the DIF Function

Introduction

When you think about looking back across observations, you either think about using retained variables or the LAG function. Retained variables allow you to access values of SAS variables from previous observations. The LAG functions (LAG, LAG2, and so forth) are more specific: they return values from previous iterations of the DATA step. One common application for a LAG function is to compare a value in the current observation to one in the previous observation. This provides you with an easy way to compute differences between observations in a SAS data ...

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