This is a possible solution although it is not in sql but it works data have; input Yearmonth ID Sales; dif= (((lag(Sales) + Sales)*100)/lag(Sales))-100; format dif 8.2; Cards; 202001 123 1000 202002 123 1500 202003 123 800 202004 123 2000 202005 123 1300 202001 456 2000 202002 456 2500 202003 456 2700 ; Run; Greetings Dilmer.
... View more