Assume a two-way data set as follows.
data data;
call streaminit(1);
do i=1 to 5;
do t=1 to 5000;
x=rand("normal");
y=x**2;
output;
end;
end;
run;
Suppose I do PROC MEANS—or any arbitrary PROC—and extract the results. I can consider three different places for ODS OUTPUT as follows.
*ods output summary=result;
proc means;
var x y;
by i;
*ods output summary=result;
run;
*ods output summary=result;
Each of the three spots creates the same resulting data set. Though I use the first place all the time and it is not a big deal in most cases, I found that it affects the results in a few rare situations, especially when there are multiple ODS statements interacting. So I just want to clarify this—which one is the most accurate way to place ODS OUTPUT?
P.S. Please avoid OUTPUT OUT= as it is a general question about ODS OUTPUT. It can be any PROC such as MEANS, UNIVARIATE, REG, AUTOREG, SURVEYREG, ARIMA, MCMC, PANEL, etc.
When someone uses a term like "correctly" my first question is define "correctly" in your problems context.
You might also provide an explicit example of when the ODS OUTPUT results in a different outcome. A data set and procedure code.
I would not be surprised that a procedure like REG could produce different output depending on where you place an output statement because the procedure supports multiple model statements and the output would depend on which MODEL statement was "active" at a given point in Proc Reg code.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.