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;
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.
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.
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;
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!
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.