Hello
I would like to ask why for 18888.88 I get 1888.88 with best. and best12. formats?
data _null_;
num = 18888.88;
int = 123456789012;
dat ='28aug17'd;
put num best12.; /* 1888.88 */
put num best. ; /* 1888.88 */
put int best. ; /* 123456789012 */
put dat best. ; /* 21059 */
run;
Do you really? I get 18888.88:
1 data _null_;
2 num = 18888.88;
3 int = 123456789012;
4 dat ='28aug17'd;
5 put num best12.; /* 1888.88 */
6 put num best. ; /* 1888.88 */
7 put int best. ; /* 123456789012 */
8 put dat best. ; /* 21059 */
9 run;
18888.88
18888.88
123456789012
21059
The BEST. format default width is 12, so these two PUT statements:
data _null_;
num = 18888.88;
put num best.;
put num best12.;
run;
will produce the same output:
18888.88
18888.88
Note that the entire value is expressed as a total of 12 characters (4 leading spaces, a 1, four 8s, a ., and two more 8s. for a total of 12 characters). If you specified a width other than the default (12):
data _null_;
num = 18888.88;
put num best.;
put num best16.;
run;
the output would be different:
18888.88
18888.88
See how that second line now has 4 more leading spaces?
I hope this helps.
Mark
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.