DATA Step, Macro, Functions and more

how to trace sas program?

New Contributor
Posts: 4

how to trace sas program?

[ Edited ]
data weight_club;  
   input IdNumber 1-4 Name $ 6-24 Team $ StartWeight EndWeight; 
1023 David Shaw          red 189 165 
1049 Amelia Serrano      yellow 145 124 
1219 Alan Nance          red 210 192 
1246 Ravi Sinha          yellow 194 177  
1078 Ashley McKnight     red 127 118  

my question is how to trace this program , line by line and control goes from which statement to which statement?


Super User
Posts: 23,771

Re: how to trace sas program?

What do you mean by TRACE? Typically this is a process to determine the flow of a program. 


What are are you looking for as output?

Super User
Posts: 5,884

Re: how to trace sas program?

You might want to look at the data step debugger. Available in DMS SAS (SAS old fat client) or the latest version of Enterprise Guide.


If that's not feasible, insert PUT statements in the code to track whats happening and what values variables have.

Data never sleeps
Super Contributor
Posts: 282

Re: how to trace sas program?


If you want to trace/debug the flow of a SAS data step, you can use the /debug option.

example: data weight_club / debug; ..... run;


To see more example and debug commands usage example, checkout this link DATA Step Debugger


Hope this helps,


Super User
Posts: 6,785

Re: how to trace sas program?

If this is what you mean by "trace", you would normally add PUT statements to a DATA step.  For example, after the DATA statement, add:


put '#1 ' _all_;


After the INPUT statement, add:


put '#2 ' _all_;


After the LOSS= statement, add:


put '#3 ' _all_;


If you are dealing with large numbers of observations, you might want to limit the number of messages you get.  For example, yo u might limit the number of observations read in using OBS=, or you might condition the PUT statements by adding:


If _n_ < 10 then put ......;

Ask a Question
Discussion stats
  • 4 replies
  • 5 in conversation