I was testing SAS numeric limit for percentage calculation.
For example,
40% is 0.4 in SAS Dataset
100% is 1 in SAS Dataset
33.333333% is 0.3333333 in SAS Dataset
Another Database team is going to populate percentage data for me. Now the question is, I tried testing in BASE SAS and I found out SAS can support up to 8 decimal places as followed.
0.12345678
There might be cases where by 100 divides by 3 will get 33.3333333.
For this, it would be Num8. with format 10.8. Is there a better way to define a SAS column for percentage instead of defining format 10.8 with Num8. especially for cases like 33.333333?
SAS uses 8 Bytes to store numbers. This allows to store 15 digits with full precision (and up to a point also numbers with 16 digits).
SAS Formats only affect how numbers get printed. SAS will use the internally stored value for any calculation (=full precision).
Have a look at below. May-be that's going to explain to you that the problem you're raising doesn't really exist.
data demo;
do var1=0.105, 1/3, 0.5, 1.6, 1;
var2=var1;
var3=var1;
var4=var1;
output;
end;
format var2 best32. var3 percent16. var4 percent16.2;
stop;
run;
proc print data=demo;
run;
Not sure what your question is. SAS stores all numbers of 64 bit floating point binary. You can have up to about 15 decimal digits of precision with such numbers. Are you asking how many characters they should use when transferring the data as text string?
@StickyRoll wrote:
I was testing SAS numeric limit for percentage calculation.
For this, it would be Num8. with format 10.8. Is there a better way to define a SAS column for percentage instead of defining format 10.8 with Num8. especially for cases like 33.333333?
Depends on what you want to see. Consider one format:
data example; x=1/3; put x=best3.; put x=best4.; put x=best5.; put x=best6.; put x=best7.; put x=best8.; put x=best9.; put x=best10.; put x=best11.; put x=best12.; put x=best13.; put x=best14.; put x=best15.; put x=best16.; put x=best17.; put x=best18.; put x=best19.; put x=best20.; run;
Look in the Log if you aren't familiar with the Put function.
Pick a format, or make one of your own, that displays things the way you want.
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.