DATA Step, Macro, Functions and more

difference between implicit output and output(explicit)

Posts: 0

difference between implicit output and output(explicit)

what is the difference between implicit output and output(explicit).i understood the difference but little confused when to use them.can anyone explain the difference ????
Posts: 0

Re: difference between implicit output and output(explicit)

Hi SD,

Sorry if my reply is late.

Since you said you know both implicit and explicit outputs, but kind of confused, let me put the diff this way:

Every data step has an implied output at the end which tells SAS to write the current observation to the output dataset before returing to the beginning of the data step to process the next observation. ( To understand this, pls visualize the actions that take place during compilation and execution, and the PDV). This is the default of any data step. But you can override this implicit output with your own (explicit) output statement.

For eg. consider you have a demographic dataset. And you want to create two datasets, one containing the male subjects and the other containing female subjects, from this original demographic datatset. It can be accomplished in a single data step by using explicit output statements:

Data male female;
set demog;
if gender='male' then output male;
else output female;

Without the two explicit output statments, it would have been difficult to create the two datasets in a single data step!!

Hope this helps.

Posts: 0

Re: difference between implicit output and output(explicit)

Explicit outputs are also useful when creating a summarized dataset that cannot be created using proc summary (proc means), or some such animal.

As an overly simplistic (and so unnecessary) example:
poc sort data=indata;
by field1 field2 field3;

data outdata;
set indata;
by field1 field2 field3;
retain count sum;
if first.field3 then do;


if last.field3 then do;
avg = sum/count;

Outdata now contains the count of field3 things for each of field1 and field2 and the average of "value" for each of the output observations. The number of observations in outdata is less than the number of observations in indata.

My example would have been just as easily done with a proc sql or proc means or proc summary, but the point is to illustrate the use of an explicit output. Sometimes there is qualifying logic that needs to be applied within the datastep that would be too complicated to implement in proc sql or impossible in proc means or proc summary.

The previous comment/posting talked about creating multiple datasets. I have used that when parsing an input text file. Given a single file that contains stock ticker information, parsing separates out three datasets, trades, quotes and other_messages: "output trades;", "output quotes;" and "output other_messages;" depending on conditional recognition of the record type.
Ask a Question
Discussion stats
  • 2 replies
  • 1 in conversation