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,
proc means data=lemon n nmiss max min;
var up down;
output out = result;
run;
so we I don't add the output out line, the result just show when I run and they are not saved anywhere right?
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.
@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.
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 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.