Based on what you provided thus far, I could not recreate the problem, with a SAS 9.1.3 SP4 environment on Windows, with a manually assigned S1_D1 initial value in a RETAIN statement.
You have an interesting challenge - continue to presume that there is something in your data or code. Suggest you add some PUTLOG _ALL_; statements before and then again after the re-assignment statements. Also, consider using ELSE "condition" tests so that only one statement test will pass, if any. Appears as though you will need to diagnose the problem further within your DATA step -- as suggested with adding PUTLOG statements along the way, at various code points.
Scott Barry
SBBWorks, Inc.