BookmarkSubscribeRSS Feed

If one uses an invalid format in %SYSFUNC, the error can go undetected:

%let date=%sysfunc(today(),xxx.);
%put &=date.;

Log:

 69         %let date=%sysfunc(today(),xxx.);
 70         %put &=date.;
 DATE=22602

The %SYSFUNC function should issue at least a NOTE to the log, like the PUT function does:

 69         data _null_;
 70         x = put(today(),xxx.);
                            ____
                            484
 NOTE 484-185: Format XXX was not found or could not be loaded.
5 Comments
Ksharp
Super User

Kurt,

I get the ERROR information. 

What sas version are you using ?

Mine is SAS9.4M7 .

 

Ksharp_0-1637239666040.png

 

Quentin
Super User

I would check the setting of the FMTERR option.  I think EG sets it to NOFMTERR by default.  Not sure about studio.  In my test on 9.4M4, it is honored:

 

1
2    options fmterr ;
3    %let date=%sysfunc(today(),xxx.);
ERROR: Format name XXX. not found or the width and/or decimal specified for the format used are out of
       range.
4    %put &=date.;
DATE=22602
5
6    options nofmterr ;
7    %let date=%sysfunc(today(),xxx.);
8    %put &=date.;
DATE=22602
Kurt_Bremser
Super User

I was referring to the different behavior. With the same options setting, PUT issues a NOTE, but %SYSFUNC does nothing. IMO, the behavior should be consistent across all uses of a format.

My test was run on On Demand (SAS Studio), BTW.

Quentin
Super User

Agree, it's inconsistent when you have NOFMTERR set. You don't get a NOTE from %SYSFUNC.

 

But happily, if you have FMTERR set, it's consistent, you get an error from %SYSFUNC and PUT.

 

1    options fmterr ;
2    %let date=%sysfunc(today(),xxx.);
ERROR: Format name XXX. not found or the width and/or decimal specified for the format used are out of
       range.
3    %put &=date.;
DATE=22602
4
5    data _null_;
6      x = put(today(),xxx.);
                       ----
                       48
ERROR 48-59: The format XXX was not found or could not be loaded.

7    run ;

NOTE: The SAS System stopped processing this step because of errors.

8
9    options nofmterr ;
10   %let date=%sysfunc(today(),xxx.);
11   %put &=date.;
DATE=22602
12
13   data _null_;
14     x = put(today(),xxx.);
                       ----
                       484
NOTE 484-185: Format XXX was not found or could not be loaded.

15   run ;

This inconsistency doesn't bother me much. If I've set NOFMTERR, it's because I've decided that I don't care about unknown formats.  So lack of a note doesn't bother be.  I think it would be a bigger problem if it didn't throw and error when FMTERR is set.

 

To my mind, the real mistake here is in EG (and I assume studio) setting NOFMTERR by default (presumably in order to make life easier for people who don't know about formats), but it's probably years too late to try and change that decision.

Kurt_Bremser
Super User

This behavior surfaced for me while helping a user (see here). If the NOTE had been there, the user would not have needed a second pair of eyes to find the problem.