UserGuide BioStat Prime Help

Lag or Lead Variable

This creates a new variable that finds the previous (lag) or next (lead) value in an existing variable based on the row position.

Lag or Lead Variable

The arguments used is executing the dialog are given as follows.

New Variable Name

Variable name to store the lagged or leading values

Variable to Lag / Lead

Specify the existing variable to extract the lagged or leading values from

Variables to Group By (optional)

Specify the variables to group by. If variables are specified here, the lagged and lead values will be obtained only within groups defined by these variables. If no variables are specified here, the lagged and leading values will be obtained based on the entire column specified in Variable to Lag / Lead. Typically, values should be sorted by the grouping variables prior to doing a lag or lead.

Lag or Lead

Choose whether user wants to find the previous (lag) or next value (lead)

Number of Positions

Specify the number of positions to lag or lead by. For example, a lagged value of 1 would extract the previous value and a lagged value of 2 would extract the value 2 positions previous.

Last modified: 31 July 2025