I think there is a typo in your IF statements. The syntax "first.var1=" is not valid SAS syntax. I assume you meant to say IF first.var1 AND var2 = 'N';