Interview Questions   Tutorials   Discussions   Programs   Videos   

SAS - What is LAG function? How is it used?

asked mar September 20, 2014 06:30 AM  

What is LAG function? How is it used?


1 Answers

answered By vishnoiprem   0  

Often times SASĀ® programmers need to retain the value of a variable in the current observation to the next observation. The LAG function can be very helpful here. A LAGn (n=1-100) function returns the value of the nth previous execution of the function. It is easy to assume that the LAGn functions return values of the nth previous observation.

Example : Create a single lag of one variable */

d ata one; input x; lagonce=lag(x); datalines; 1 2 3 4 5 ; proc print data=one; title 'Sample1: Single lag of one variable'; run;

   add comment

Your answer

Join with account you already have



 Write A Tutorials
Online-Classroom Classes

  1 person following this question

  Question tags

sas × 1

Asked 2 years and 3 months ago ago
Number of Views -472
Number of Answers -1
Last updated
3 years and 2 months ago ago

Ready to start your tutorial with us? That's great! Send us an email and we will get back to you as soon as possible!