Help using Base SAS procedures

ODS output

Accepted Solution Solved
Reply
Regular Contributor
Posts: 216
Accepted Solution

ODS output

Hi

In the below code, do I need to close ODS (ods listing closeSmiley Wink after the first proc lifetest and prior to the second proc lifetest steps?

Paul

proc lifetest data=s10;

  ods select Quartiles;

  ods output Quartiles=annual;

  time dur_filing_issuejoin*censor_filing_issue(1);

  strata cnty_name filingYear;

run;

data s10ERT;

set work.s10;

if cnty_name in ('county1', 'County2');

run;

proc lifetest data=s10ERT;

  ods select Quartiles;

  ods output Quartiles=annualnyc;

  time dur_filing_issuejoin*censor_filing_issue(1);

  strata filingYear;

run;

ods listing close;


Accepted Solutions
Solution
‎11-15-2012 12:43 PM
SAS Super FREQ
Posts: 8,868

Re: ODS output

Hi:

  You're both right. Some procedures MUST have at least one destination open in order to produce results. The report procedures and graph procedures generally fall in this category. For ODS OUTPUT, it is a destination (just not a report destination), so even if you close LISTING, ODS OUTPUT is a valid destination for creation of an output dataset.

cynthia

View solution in original post


All Replies
Super User
Posts: 19,872

Re: ODS output

What are you trying to do?

Suppress all output to the listing tables?

You can use ods listing close before both or ods noresults before both.

You can also use the where clause in proc lifetest, you don't need to create that second dataset.

Super User
Posts: 11,343

Re: ODS output

A generic ODS sandwich to prevent output going to listing but to your desired ods destination looks like:

ods listing close;

ods <output type> <options>;

/* procedures and output generators here*/

ods <output type> close;

ods listing ;

This sends all of the output between the ODS output destination statements to a single file. If you need to redirect to another output destination put the new ODS output destination in the middle but you dont' need to repeat the listing close.

However you arrange your ODS destinations at least one must be open when output is generated.

Super User
Posts: 19,872

Re: ODS output

ballardw wrote:

However you arrange your ODS destinations at least one must be open when output is generated.

No it doesn't...

Super User
Posts: 11,343

Re: ODS output

In 9.2 here's what happens when attempting to print with all destinations closed:

 

1 ods _all_ close;

2

3 proc print data=sashelp.class; run;

WARNING: No output destinations active.

NOTE: PROCEDURE PRINT used (Total process time):

real time 0.00 seconds

cpu time 0.00 seconds

And no output generated. ODS output seems to require and ODS destination.

Super User
Posts: 19,872

Re: ODS output

But if you're trying to capture tables it works fine:

21   ods _all_ close;

22   proc means data=sashelp.class;

23   var height weight;

24   ods output summary=summary1;

25   run;

NOTE: The data set WORK.SUMMARY1 has 1 observations and 12 variables.

NOTE: There were 19 observations read from the data set SASHELP.CLASS.

NOTE: PROCEDURE MEANS used (Total process time):

      real time           0.01 seconds

      cpu time            0.00 seconds

Solution
‎11-15-2012 12:43 PM
SAS Super FREQ
Posts: 8,868

Re: ODS output

Hi:

  You're both right. Some procedures MUST have at least one destination open in order to produce results. The report procedures and graph procedures generally fall in this category. For ODS OUTPUT, it is a destination (just not a report destination), so even if you close LISTING, ODS OUTPUT is a valid destination for creation of an output dataset.

cynthia

Super Contributor
Posts: 1,636

Re: ODS output

Hi,

I suggest you changing

if cnty_name in ('county1', 'County2');

to

if upcase(cnty_name) in ('COUNTY1', 'COUNTY2');

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 659 views
  • 3 likes
  • 5 in conversation