A SAS sandwich to satisfy every appetite

1

How do you like your sandwich? On rye, whole wheat or white bread? What fillings and dressings do you like?

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

Share

About Author

Charu Shankar

Technical Training Specialist

Charu Shankar has been a Technical Training Specialist with SAS since 2007. She started as a programmer, and has taught computer languages, business and English Language skills. At SAS, Charu teaches the SAS language, SQL, SAS Enterprise guide and Business Intelligence. She interviews clients to recommend the right SAS training to help them meet their needs. She is helping build a center for special needs kids in this project. http://www.handicareintl.org/pankaja/pankaja.swf

1 Comment

  1. Your presentation mode of explaining is really awesome Charu. One of your posts "How to land a job as a < a href = "http://www.epoch.co.in/">SAS programmer>" really made me passionate and literally I poured all your thoughts to the candidates at our centre

Back to Top