ScuzzyJo
asked on
SAS Replace dots (nulls) with zero
Hi
I have imported a file from Excel into SAS Enterprise Guide 4.3 and have performed some calculations on the data. I need to replace the dots or nulls with zero. I'm hoping to be able to do this in the "interactive" bit as I'm fairly new to SAS and haven't got as far as coding yet.
Any idea how I can do this? I'm awarding 500 points for a quick, working answer.
Thanks
Sarah
I have imported a file from Excel into SAS Enterprise Guide 4.3 and have performed some calculations on the data. I need to replace the dots or nulls with zero. I'm hoping to be able to do this in the "interactive" bit as I'm fairly new to SAS and haven't got as far as coding yet.
Any idea how I can do this? I'm awarding 500 points for a quick, working answer.
Thanks
Sarah
ASKER
Hi Iowaloysius
I've used the sum function, which is working fine in this case as the two numbers I want to add have one as a positive and one as a negative. If they were both positive, how would I do that? Can you nest the field1 - field2 inside a coalesce function or do you have to calculate the two columns separately first - once to replace the nulls with zero and once to turn one of them to a negative? Obviously, doing it in one go would be more efficient, but I'm not sure whether or not I can do this?
Thanks
Sarah
I've used the sum function, which is working fine in this case as the two numbers I want to add have one as a positive and one as a negative. If they were both positive, how would I do that? Can you nest the field1 - field2 inside a coalesce function or do you have to calculate the two columns separately first - once to replace the nulls with zero and once to turn one of them to a negative? Obviously, doing it in one go would be more efficient, but I'm not sure whether or not I can do this?
Thanks
Sarah
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
coalesce(field, 0);
otherwise, if you wish to directly perform operations like add or subtract, use the sum function, which will treat null as zero.. directly using the mathematical operators will result in null