@ResoluteCarbon wrote:
Hi all,
When calculating one variable, I accidentally calculate the same named variable by two different methods, they all in the same dataset:
x= y-z;
x=m-n;
I am wondering whether the previous x will be replaced totally by the later x? Or just be replaced partly? Is there any exception that the later x just replace the former x partly?
Thank you.
Yep.
When executing code in a data step it evaluates things from the "top" of the data step code to the bottom.
So if you assign a different value on a line below the first assignment the bottom one is the result.
The "exceptions" would all come if one or both of the assignments are conditional.
If sex='F' then x = (some calculation based on the sex);
else if sex='M' then x = (different calculation based on sex);
There is no "partly" unless you mean a character value where you assign different bits and pieces, which is possible but you would need to do the coding to implement such. With numeric values, not going to happen.
... View more