BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
swayto
Fluorite | Level 6

I tried to understand BEST12 formatting but the manuals do not explained it to my understanding. can somebody explain it with example for me? 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

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

 

View solution in original post

1 REPLY 1
Kurt_Bremser
Super User

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 Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 777 views
  • 2 likes
  • 2 in conversation