Debugging and Testing DATA Steps |
Testing Your
Programs |
Writing a NULL Data Set
When you write or edit a DATA step, you can compile and execute your program without creating observations. This enables you to catch the most common errors and saves you development time. A simple way to test a DATA step is to specify the keyword _NULL_ as the data set name in the DATA statement. data _null_; set finance.loans; Interest=amount*rate; run; When you submit the DATA step, no data set is created, but any compilation or execution errors are written to the log. Once you have corrected any errors, you can replace _NULL_ with the name of the data set you want to create.
Another way to test a DATA step is to set the OBS= system option to 0 before the DATA step is processed. You can do this with an OPTIONS statement as shown below. The OBS= option limits the number of observations read or created during execution of the DATA step. options obs=0; data finance.newcalc; set finance.loans; Interest=amount*rate; run; When processed, this DATA step creates the Finance.Newcalc data set with variables but no observations. Before running your tested and debugged DATA step, be sure to first submit another OPTIONS statement to reset the value of OBS= in order to execute all observations in your data set. You can set OBS= to MAX in order to process the maximum number of observations. MAX is the default setting. options obs=max; data finance.newcalc; set finance.loans; Interest=amount*rate; run;
|
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.