I tried to understand BEST12 formatting but the manuals do not explained it to my understanding. can somebody explain it with example for me?
SAS will reserve space for 12 characters to be displayed, and then it will fit the number into it as good as possible.
If up to 12 digits left of the decimal point are present in your number, the number will be displayed in the usual way, digits to the right of the decimal point will be discarded once they exceed the 12 spaces.
As long as no more than 12 digits (including the decimal point) are present, everything will be displayed, with the decimal point shifting to wherever it ends up.
Numbers with more than 12 digits to the left will be displayed in scientific notation.
Run this code to illustrate this:
data test;
input number;
format number best12.;
datalines;
1
1.25
1.23456
123456789.12345
123456789012.12345
1234567890123
;
run;
proc print data=test noobs;
run;
Result:
number 1 1.25 1.23456 123456789.12 123456789012 1.2345679E12
SAS will reserve space for 12 characters to be displayed, and then it will fit the number into it as good as possible.
If up to 12 digits left of the decimal point are present in your number, the number will be displayed in the usual way, digits to the right of the decimal point will be discarded once they exceed the 12 spaces.
As long as no more than 12 digits (including the decimal point) are present, everything will be displayed, with the decimal point shifting to wherever it ends up.
Numbers with more than 12 digits to the left will be displayed in scientific notation.
Run this code to illustrate this:
data test;
input number;
format number best12.;
datalines;
1
1.25
1.23456
123456789.12345
123456789012.12345
1234567890123
;
run;
proc print data=test noobs;
run;
Result:
number 1 1.25 1.23456 123456789.12 123456789012 1.2345679E12
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.