BookmarkSubscribeRSS Feed

Hi , guys!

 

Recently I am studying the macro code in the autocall macro in SAS. And I found ther is an error in the autocall macro BUILSFMT source code, which is located in directory: !SASROOT\core\macro.

 

When I try to call this macro:

 

 

%buildFmt(formatName=agefmt,lookupTable=sample,startColumn=age,labelColumn=age_label);

 

And an ERROR occured:

log_error.png

 

 

So I check the source code of macro BUILDFMT, and I found the reaon. The author missed two semicolons. Right here:

code_error.png

 

These two missed semicolons cause the error above. Just like Lora D. Delwiche and Susan J. Slaughter writed in the Little SAS Book: "Even the most experienced SAS programmer will at least occasionally forget the semicolon."Smiley LOL

 

So, next I am wondering the error jsut in my SAS? Or in all of the SAS? So I check my colleague's SAS which is SAS 9.3, mine is SAS 9.4. His also has the error. So, is there this error in your SAS?

 

3 Comments
Reeza
Super User

Did you report to Tech Support or check if there was a SAS note already? 

Tom
Super User
Super User

There was a change to the way that SAS compiled macros (back in version 9.2 I think?) that makes this macro no longer compile.  Previously it would ahve compiled ok and only generated the syntax error when it actually tried to execute those particular statements.  We found a number of our standard macros that had similar bugs that had never been caught.

 

Makes me wonder if anyone is using this SAS supplied macro.

 

If someone does update this file here are two other obvious issues.

1) The comment block that show example call uses the macro name BUILDFORMAT instead of the actual macro name of BUILDFMT.

2) The macro does not handle one level dataset names properly.  If you want to reference a work dataset you need call it with WORK.MYDATA instead of just MYDATA.

 

885  options mprint;
886  %buildfmt
887  (formatName= gender
888  ,lookupTable= gender
889  ,startColumn= code
890  ,labelColumn= decode
891  ,blanks=
892  );
ERROR: The function DEQUOTE referenced by the %SYSFUNC or %QSYSFUNC macro function has too few
       arguments.
MPRINT(BUILDFMT):   data _null_;
MPRINT(BUILDFMT):   dsid = open("gender.");
MPRINT(BUILDFMT):   call symput("dsid", compress(put(dsid, 10.)));
MPRINT(BUILDFMT):   if (dsid gt 0) then do;
MPRINT(BUILDFMT):   varnum = varnum(dsid, "code");
MPRINT(BUILDFMT):   call symput("startVar", compress(put(varnum, 10.)));
MPRINT(BUILDFMT):   if (varnum gt 0) then call symput("startType", vartype(dsid, varnum));
MPRINT(BUILDFMT):   varnum = varnum(dsid, "decode");
MPRINT(BUILDFMT):   call symput("labelVar", compress(put(varnum, 10.)));
MPRINT(BUILDFMT):   if (varnum gt 0) then call symput("labelType", vartype(dsid, varnum));
MPRINT(BUILDFMT):   call symput("anyRecords", put(attrn(dsid, "ANY"), 1.));
MPRINT(BUILDFMT):   dsid = close(dsid);
MPRINT(BUILDFMT):   end;
MPRINT(BUILDFMT):   run;

NOTE: DATA statement used (Total process time):
      real time           0.26 seconds
      cpu time            0.01 seconds


ERROR: The lookupTable could not be opened.

It also builds a character format even when the START column is numeric. 

Reeza
Super User

Didn't even know they existed personally. Wondered if it was something specific to the users setup initially, ie a custom company macro.