You probably think I’ve gone completely crazy and I don’t blame you. What does food have to do with SAS, you say? Loads -- as you’ll find out with this student question…
“Is there an easy way to select an output and paste it into a report in SAS?”
It looks like this student is really hungry for more. Shall we satisfy the student’s SAS appetite with a sandwich?
Some history for you, before Version 7, SAS output was married to the SAS output window, aka the Listing destination. To better accommodate users who needed to share their SAS output with non SAS people, SAS 8.2 came out with ODS or the output delivery system.
ODS uses the sandwich technique. Much like you can have a slice of bread to start the sandwich with, some filling and a slice to close it off, the ODS technique gives SAS users the freedom to send output to a variety of flavors. Don’t you just love free will to create output your mind desires?
At its most basic there are just three lines of code:
ODS destination <FILE=filename>; ...SAS procedure syntax... ODS <destination> CLOSE;
As an example let’s send proc freq output from the cars dataset in the SASHELP library to HTML:
Voila! You’re done. All our happy user needs to do now is to just open the cars.html file outside of SAS. No more copy and pasting!! No more having to depend on a SAS installation on user machines to view output.
It only gets better and better. Just like you can make a sandwich with different types of bread, you can send your SAS procedure to different output destinations like PDF, RTF, and even Excel.
And much like you have the option to choose fillings, you can select the SAS procedure(s) you want. And remember you are not limited to having one filling or one procedure, you can embed as many Procs as your heart desires in one ODS destination file.
I’ll leave you with this handy sheet on the output delivery system. And another great tip sheet for many more options including SAS output to Excel. Talk of all this food has me really famished. I hope you’ll forgive me as I go make myself a sandwich.
photo credit: Debs (ò‿ó)♪ // attribution: creative commons