BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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 ????
2 REPLIES 2
deleted_user
Not applicable
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;
run;

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

Hope this helps.

Cathy
deleted_user
Not applicable
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:
[pre]
poc sort data=indata;
by field1 field2 field3;
run;

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

count+1;
sum+value;

if last.field3 then do;
avg = sum/count;
output;
end;
run;
quit;
[/pre]

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.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 8780 views
  • 1 like
  • 1 in conversation