Вопрос

I am converting a character variable to a numeric variable. I am using a bestw.d format. I also tried just best. as the format in the input statement and this worked fine. I cant find any mention of just using best. instead of bestw. in SAS help, though I know from SAS help that the d can be omitted. I have been playing around with using just the best.and I am wondering if there is a default w assigned when just using best..

Это было полезно?

Решение

All formats have a default w. It is not generally good practice to use best. (or <format>.) in most cases, as you should know and plan for the specific width needed, but it always exists.

Also, informat and format have different defaults in many cases where there are identically named informat and format.

In the case of bestw., the default length is 12. See this documentation page for details.

Другие советы

I always find it's worth using a worked example, this shows the different outcomes when using lengths on the BEST. format:

data _NULL_;
a=1031564321300.302;
  put '==================================';
  put 'Different "BEST" formats';
  put '==================================';
  put 'BEST8. - ' a best8.;
  put 'BEST12. - ' a best12.;
  put 'BEST13. - ' a best13.;
  put '==================================';
  put 'BEST. - ' a best.;
  put '==================================';
run;

You can run this in your environment and check the outcome. On my machine it looks like this:

==================================
Different "BEST" formats
==================================
BEST8. - 1.032E12
BEST12. - 1.0315643E12
BEST13. - 1031564321300
==================================
BEST. - 1.0315643E12
==================================

i.e. It looks like BEST12. is the matching format when no width is specified.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top