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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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