This rather looks like a rounding problem, than a format problem.
ROUNDing the result of your VAL3 variable to, say, 0.0001 would work just fine.
val3=ROUND (Sum(0,val1)-Sum(0,val2), .0001) ;
See problems and discussions about SAS rounding in the documentation : http://support.sas.com/onlinedoc/913/getDoc/fr/lrcon.hlp/ a000695157.htm (you have to suppress the space character in the web adress, but if I don't type it, I have .ht displayed instead of .htm).
Call for content now open!
It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.