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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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