|
|
|
||||
|
|
|||||
Two SAS system options are very helpful in debugging macro programs. They are mprint and mlogic.
Let's take a look at an example. In the macro program below, a data set with a given name and a given number of observations is generated.
%macro test(num, data);
data &data;
do i = 1 to #
x = ranuni(-1);
output;
end;
run;
proc means data = &data;
var x;
run;
%mend;
How do we know what is happening when we run this macro program? Let's turn on the option of mprint and mlogic and run the program.
options mprint mlogic; %test(10, test);
In the log window, we will see the following.
1246 options mprint mlogic; 1247 %test(10, test); MLOGIC(TEST): Beginning execution. MLOGIC(TEST): Parameter NUM has value 10 MLOGIC(TEST): Parameter DATA has value test MPRINT(TEST): data test; MPRINT(TEST): do i = 1 to 10; MPRINT(TEST): x = ranuni(-1); MPRINT(TEST): output; MPRINT(TEST): end; MPRINT(TEST): run; MPRINT(TEST): proc means data = test; MPRINT(TEST): var x; MPRINT(TEST): run; MLOGIC(TEST): Ending execution.
As shown above, option mlogic tells us the parameter values and option mprint translates the macro language to regular SAS language.
UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services