SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
HeatherNewton
Quartz | Level 8

how to output proc mean results in a dataset?

 

data lemon;
  input up down sub_product $;
datalines;
2   5    apple
3   2    lemon
run;

proc print data=lemon;
run;


proc means data=lemon output=result n nmiss max min;
var up down;
run;

proc print data=result;
run;

how to output result in a data set, I tried the above and it does not work. Please help thanks,

5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20
proc means data=lemon n nmiss max min;
   var up down;
   output out = result;
run;
HeatherNewton
Quartz | Level 8

so we I don't add the output out line, the result just show when I run and they are not saved anywhere right?

Rick_SAS
SAS Super FREQ

Correct. By default, PROC MEANS displays the results but does not save them to a data set. In addition to the OUTPUT statement, you can also capture output from SAS procedures by using the ODS OUTPUT statement, which enables you to store any statistic from any procedure.

 

If you ever want to analyze more than one variable at a time and save the statistics, read about how to save descriptive statistics for multiple variables in a SAS data set.

ballardw
Super User

@HeatherNewton wrote:

so we I don't add the output out line, the result just show when I run and they are not saved anywhere right?


Ancient history lesson: Once upon a time when most computing was done on main frames and disk storage was expensive Proc Means did not create data sets at all, only output to line printers (actual paper output). Proc Summary only created output datasets using similar syntax to Proc Means but did not create printed output. As computers became cheaper and output changed to mostly monitor, output the two procedures were in effect merged so Proc Means creates output. BUT by default to honor the intent of code that may have been written a long time ago Means does not create output data sets by default and you have to request them. Or use Proc Summary which will not create printed (results output) unless specifically requested and will want to make an output data set expecting an OUTPUT statement.

Reeza
Super User

Yes, but you can also suppress that output if you'd like using NOPRINT or ODS SELECT/EXCLUDE.

 

See this example for two ways to capture the output.

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p17h6q7ygvkl1sn13qzf947dundi.htm

 

Here's some instructions and explanations on how to capture output that is shown.
https://blogs.sas.com/content/sastraining/2017/03/31/capturing-output-from-any-procedure-with-an-ods...

 


@HeatherNewton wrote:

so we I don't add the output out line, the result just show when I run and they are not saved anywhere right?


 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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
  • 5 replies
  • 876 views
  • 2 likes
  • 5 in conversation