BookmarkSubscribeRSS Feed
Ronein
Meteorite | Level 14

Hello

What does it mean debug information?

In which situation we need to use this type of code ?

I will appreciate if anyone can explain it.

I saw the defintion of debugging "Debugging is the routine process of locating and removing computer program bugs, errors or abnormalities, which is methodically handled by software programmers viadebugging tools. Debugging checks, detects and corrects errors or bugs to allow proper program operation according to set specifications"

Thanks

Joe

 

/* Conditionally produce debugging information */
%let _DEBUG = 0; /* set to 1 for debugging */
%if &_DEBUG. %then
  %do;
    proc print data=sashelp.class(obs=10);
    run;
  %end;

 

 

4 REPLIES 4
Astounding
PROC Star

Some of us programmers who are not as talented as you are ... we occasionally make mistakes.  We might want additional information to help us figure out where the mistakes are and what to fix.  In this case, that information is to print the first ten observations of a data set.  But once the mistakes are fixed, we don't want to print those 10 observations any more.  So in this example, the debugging information is the printing of 10 observations that we can turn on by setting &_DEBUG to 1, and turn off by setting &_DEBUG to 0.

Ronein
Meteorite | Level 14

Thank you.

Usually I  turn off  print by put it in notes (/************************/)

As I understand ,alternatively, I can change the value in %let  _DEBUG from 0 to 1 

%let _DEBUG = 0;

 

Shmuel
Garnet | Level 18

There are no builtin options in sas to debug a program.

You can find some system variables to be checked: &syserr, &sysrc and others.

Usually if you observe an error, either in log or in your output, you need to DEBUG your program

by adding specific code which should not run after all errors corrected.

 

you can use a flag to define whether to run your debugging code or not, like in your example,

or you can enclose that code by *...; or by /*....*/.

 

If you prefer the 2nd method, than you can easily find that specific code if you mark it as::

/*DEBUG*/ ... any debugging code ...  

  

Astounding
PROC Star

You have to consider the entire example, and put it in a larger context.

 

Context:  Suppose you have 10 PROC PRINTs and 5 PROC CONTENTs that you want to run only if there is trouble.  It's a lot of work to find and either comment or uncomment 15 procedures.  And you might miss one or two.  Instead, you can set up a macro variable that automatically turns all 15 procedures on or off.  

 

Example:  In the code that you posted, there was some careful work done beforehand when composing the program.  You can't just switch a macro variable on or off and expect it to do anything at all.  You have to build it into the program.  In your sample code, the programmer built in a macro condition:  %if &_ERROR %then .....  That was part of the planning, and part of the program that lets the setting of &_ERROR control whether or not the PROC PRINT executes.

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
  • 4 replies
  • 502 views
  • 0 likes
  • 3 in conversation