RETAIN causes a variable that is created by an INPUT or assignment statement to retain its value from one iteration of the DATA step to the next.
Without a RETAIN statement, SAS automatically sets variables that are assigned values by an INPUT or assignment statement to missing before each iteration of the DATA step.
So if 'var' is a new variable for the dataset(s) read from set statement, results of the two statment are the same. But if 'var' has existed in the dataset(s), the results will be distinct.