BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
eshupp
Obsidian | Level 7

Based on information I have found on other sites and a SUGI paper written by Paul Sherman it appears that ERROR messages like "NOTE: Invalid second argument to function SUBSTR at line nnnnn column nnn" are actually indicating macro BLOCK and COLUMN rather than open code LINE and COLUMN.  My question is, if I turn on MACRO options like MPRINT or MGEN or MLOGIC how can I determine the block numbers in the output.  Is there some undocumented automatic macro variable like &SYSMACBLOCK that I could %PUT to the log to identify more closely which of my generated statements is generating the note when I have lots of SUBSTR calls? 

1 ACCEPTED SOLUTION

Accepted Solutions
Quentin
Super User

@eshupp wrote:
Easier said than done when your error is in block 58296. If SAS knows which block the error is in I should have some way to display block numbers in the debugging output other than paging through thousands of lines of SASLOG. With open code errors the line numbers are displayed but MPRINT does not provide the same information.

Yeah, it would be nice if you could do this, but you can't.  It's one of the limitations of the the way the macro processor was designed that a macro doesn't have line breaks in it (which is why you can't use CARDS in a macro).  So when the macro generates lines of code and sends them to SAS to be compiled and executed, my guess is it's all one line (in a sense). So the log can't tell you a useful line number for an error.

 

One workaround some folks use is to use MPRINT and MFILE to create a .sas file with no macro code, which can then be %included to generate a log with useful line numbers for errors.  See e.g. https://support.sas.com/resources/papers/proceedings14/1302-2014.pdf

 

BASUG is hosting free webinars Next up: Mike Raithel presenting on validating data files on Wednesday July 17. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

View solution in original post

6 REPLIES 6
Tom
Super User Tom
Super User

That way madness lies 

Just turn on MPRINT and check the log for your mistakes.

If you are really desperate then turn on SYMBOLGEN and/or MLOGIC and slog your way through the reams of log messages.

Or better still put in some PUT or %PUT statements to debug where the errors are.

eshupp
Obsidian | Level 7
Easier said than done when your error is in block 58296. If SAS knows which block the error is in I should have some way to display block numbers in the debugging output other than paging through thousands of lines of SASLOG. With open code errors the line numbers are displayed but MPRINT does not provide the same information.
PaigeMiller
Diamond | Level 26

With MPRINT on, the ERROR messages appear immediately below the actual error (just as they do when you are not running macro code), plus you can see the actual SAS code that you macro has created; and you don't need a line number of block number to find them.

 

... other than paging through thousands of lines of SASLOG ...

 

No need to do that. Using the search function in the LOG window (ctrl-F) will get you there quickly.

--
Paige Miller
Quentin
Super User

@eshupp wrote:
Easier said than done when your error is in block 58296. If SAS knows which block the error is in I should have some way to display block numbers in the debugging output other than paging through thousands of lines of SASLOG. With open code errors the line numbers are displayed but MPRINT does not provide the same information.

Yeah, it would be nice if you could do this, but you can't.  It's one of the limitations of the the way the macro processor was designed that a macro doesn't have line breaks in it (which is why you can't use CARDS in a macro).  So when the macro generates lines of code and sends them to SAS to be compiled and executed, my guess is it's all one line (in a sense). So the log can't tell you a useful line number for an error.

 

One workaround some folks use is to use MPRINT and MFILE to create a .sas file with no macro code, which can then be %included to generate a log with useful line numbers for errors.  See e.g. https://support.sas.com/resources/papers/proceedings14/1302-2014.pdf

 

BASUG is hosting free webinars Next up: Mike Raithel presenting on validating data files on Wednesday July 17. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
eshupp
Obsidian | Level 7
Thanks! That sounds like a great option. I have never used the MFILE option before but I will give it a try!
eshupp
Obsidian | Level 7
Using the MPRINT and MFILE options I was able to finally identify the SUBSTR functions that were generating the NOTE statements quickly. Thanks again!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 6 replies
  • 465 views
  • 2 likes
  • 4 in conversation