I got a question about how to export a graph in SAS to a program like PowerPoint. There are several ways to do this, and I explained that you can right click on any graph that appears on your screen and copy it to the clipboard and then open up PowerPoint and right click on a slide and paste it in. That’s fairly standard on any Windows system. I presume that SAS supports similar approaches on the Macintosh and Linus, but I have no easy way of testing this.

But there are other ways to export a graph. You can tell SAS to save a particular graph to a file and then you can import that file into PowerPoint. It works, but there is a twist.

I found a really simple example of saving a SAS graph as a file, and I adapted the code. It takes advantage of the very useful built-in data sets. Thank you SAS! Here’s’ the code.

* graph_export.sas;
* written by Steve Simon;
* March 23, 2018;

ods graphics off;
filename grafout 'c:\temp\temp.gif';
goptions reset=all gsfname=grafout gsfmode=replace device=gif;
proc gchart data=sashelp.class;
vbar age / discrete;
title 'Age Distribution for Students';
run;
quit;
filename grafout clear;

It didn’t work and it took me forever to figure out why. Let me show you what the log window looks like when you run this on my system.

NOTE: Writing HTML Body file: sashtml.htm
NOTE: 8894 bytes written to C:\Users\simons\AppData\Local\Temp\SAS Temporary