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.
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
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.
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?
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.