BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Junyong
Pyrite | Level 9

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ
Hi:
My tendency is to always put it as the statement immediately before the procedure that will be sending it output.
In the examples in the documentation, https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=odsug&docsetTarget=p0o... the ODS OUTPUT statement is always put BEFORE the PROC statement, so that is model I follow. Other places MIGHT work, but I find that if I am consistent this way, then I always get the results I expect.

My .02, bolstered by the doc,
Cynthia

View solution in original post

2 REPLIES 2
Cynthia_sas
SAS Super FREQ
Hi:
My tendency is to always put it as the statement immediately before the procedure that will be sending it output.
In the examples in the documentation, https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=odsug&docsetTarget=p0o... the ODS OUTPUT statement is always put BEFORE the PROC statement, so that is model I follow. Other places MIGHT work, but I find that if I am consistent this way, then I always get the results I expect.

My .02, bolstered by the doc,
Cynthia
ballardw
Super User

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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 351 views
  • 0 likes
  • 3 in conversation