There is a concept of PDV in SAS, the Program Data Vector is a logical area of memory that is created during the data step processing. SAS builds a SAS dataset by reading one observation at a time into the PDV and, unless given code to do otherwise, writes the observation to a target dataset.So here in the beginning as per the data step, the amount=4; then the same values is used to fill the value of variable amount=4, then the if/then step is read and since amount=4 when its read the word variable is set to FOUR, then again the amount variable is read again and this time since the value is 7 the amount of 4 is overwritten with 7. And since after this there is no if/then the same values will remain and are output.
Thanks,
Jag