BookmarkSubscribeRSS Feed
Fluorite | Level 6

Hi Folks,

just like in python ( i am looking for way to trace execution of SAS program step by step but unfortunately i did not found any such option.

I also tried debug data set option but it is of no use. 

Is there a way to trace execution of program and see its result step by step then kindly share those information.


Thank you.

Quartz | Level 8

It depends on what level of tracing you want to apply and what kind of code do you run.  @Ajayvit 


For example if you have a sas macro then you can use below line in the beginning. It will print all the details in the logs.


options mlogic mprint symbolgen;

Here are some other resources for different use cases and techniques:

SASTRACE= SAS System option:

Through SMC:


Mayur Jadhav
BI Developer. Writer. Creative Educator.

SAS Blog →
YouTube Channel: →
Onyx | Level 15

I have rather grim news for you. It can be done only partially, and without understanding the code logic it's rather "fail". Except those 3 options: mprint, mlogic, and symbolgen, mentioned by @MayurJadhav there is also one called MFILE which allow to store generated 4GL in a text file. But.. even if you decide to turn them on:

filename mprint "C:\text.txt";
options mfile mprint mlogic symbolgen;

you can easily find examples of macros which will never give you any "info" how they work... like those 3 examples:

%macro test0(dset);
  %local rc Variables;
  %let rc = %sysfunc(DoSubL(%str(
     options nonotes nosource nomprint nosymbolgen nomlogic;
     proc transpose data = &dset.(obs=0) out = _tmp(keep = _name_);
      var _all_;
     proc sql noprint;
      select _name_ 
      into :Variables separated by " "
      from _tmp;
      drop table _tmp;
%mend test0;

%macro test1()/secure;
  data _null_;
    put "This is top secret data step";
%mend test1;

%macro test2()/secure;
  %local temp_options;
  %let temp_options = 
  options nomprint nosymbolgen nomlogic;

  data _null_;
    put "This is top secret data step number 2";

  options &temp_options.;
%mend test2;

%put *%test0(sashelp.class)*;

The first one with the DoSubL() function embedded, the second with Secure option on, and the third with options turned off inside it.







Polish SAS Users Group: and

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation


What are you trying to do exactly? SAS programs typically execute serially. If you have SAS macros then the MPRINT option will print the actual SAS statements executed. The DATA step debugger can step you through the the logic as each row is read. Personally I've never found a need to use it.


In my experence the SAS log provides enough information to understand the order of processing and evidence of any problems. What do expect a tracer to provide that the SAS log can't?


Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.


Register now!

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
  • 5 in conversation