BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Nietzsche
Lapis Lazuli | Level 10

the two codes below produced the same result. So what is the point of the output; statement?

data cars2 (drop=color);
	set spg.cars;
	if color='G';
	output;
run;
proc print data=cars2;run;
data cars2 (drop=color);
	set spg.cars;
	if color='G';
run;
proc print data=cars2;run;

Nietzsche_0-1669833236457.png

 

SAS Base Programming (2022 Dec), Preparing for SAS Advanced Programming (Cancelled).
1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

In this example, the outcome is the same. But there are numerous examples where an explicit Output Statement is quite handy. In your example, there is an implicit Output Statement (And Return Statement) at the bottom of the Data Step. 

 

Consult the Output Statement Doc for information and examples. 

View solution in original post

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

In this example, the outcome is the same. But there are numerous examples where an explicit Output Statement is quite handy. In your example, there is an implicit Output Statement (And Return Statement) at the bottom of the Data Step. 

 

Consult the Output Statement Doc for information and examples. 

PaigeMiller
Diamond | Level 26

In the simple example you have, OUTPUT really has no impact, but in other cases OUTPUT could be useful.

 

Example:

 

data cars2 (drop=color);
	set spg.cars;
	if color='G';
        /* perform some complicated calculation that takes 10 steps and generates a value in variable RESULT */
	if result<0 then output;
run;

 

--
Paige Miller

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 797 views
  • 0 likes
  • 3 in conversation