BookmarkSubscribeRSS Feed
Ajayvit
Fluorite | Level 6

Hi Folks,

just like in python (https://pythontutor.com/) 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.

4 REPLIES 4
MayurJadhav
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: https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/acreldb/n0732u1mr57ycrn1urf24gzo38sc.htm

Through SMC: https://support.sas.com/kb/43/157.html

 

Mayur Jadhav
BI Developer. Writer. Creative Educator.

SAS Blog → https://learnsascode.com
YouTube Channel: → https://www.youtube.com/@imayurj
yabwon
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_;
     run;
     proc sql noprint;
      select _name_ 
      into :Variables separated by " "
      from _tmp;
      drop table _tmp;
     quit; 
  )));
  &Variables.
%mend test0;

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

%macro test2()/secure;
  %local temp_options;
  %let temp_options = 
    %sysfunc(getoption(mprint))
    %sysfunc(getoption(symbolgen))
    %sysfunc(getoption(mlogic))
    ;
  options nomprint nosymbolgen nomlogic;

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

  options &temp_options.;
%mend test2;


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

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

 

 

 

Bart

 

 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"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



SASKiwi
PROC Star

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?

sas-innovate-2024.png

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
  • 587 views
  • 3 likes
  • 5 in conversation