I have the following data:
input_table (ordered by customernumber, code number):
I'd like to use lag to look 2 rows prior, determine if the customernumber is the same for the prior 2 customernumber rows, then look at the code number, and determine if I'm on code number c1, and if so look back at the 2 prior code number rows are a1 and b1. If so, this meets the criteria I'm looking for. As an example, customernumber 1 is the only one above that matches this criteria. I'm using the following SAS code to do this, using lag. Please let me know if this looks good, thx!
libname sassvrtable 'my/sasdatabase/table'