Editor's note: SAS programming concepts in this and other Free Data Friday articles remain useful, but SAS OnDemand for Academics has replaced SAS University Edition as a free e-learning option. Hit the orange button below to start your journey with SAS OnDemand for Academics:
I, like many people around the world, love McDonald’s. However, every time I go, I hear my mom’s voice in my head saying how bad it is for me, that I should eat my vegetables, etc. I usually justify it by telling myself it’s once in a while, I’ve had a hard week, etc.
But then I found McDonald’s nutritional data and starting playing around with it. Turns out mom's right. There is a lot of salt and fat in their food, at least according to their U.S. menu. I figured I should share this information with my mom to show her that she’s right -- and show off my SAS skills 🙂
So for today's installment of Free Data Friday, I'll use this fast-food data to highlight ways you can export your graphs from SAS.
The data can be downloaded on Kaggle; it’s an extremely small-sized file (<10kb) but has a lot of information. The file imported into SAS without issue.
The data was already in a format that I could use, as it was in standard CSV format.
Although I ran multiple analyses, I’m going to focus on one scatterplot that I did. The steps to export the other graphs are the same.
Using the Scatterplot Task, I put Sodium on the x-axis and Total Fat on the y-axis. I grouped by Menu Category (Breakfast, Desserts, etc).
(Note: The extreme outlier is the 40-piece Chicken McNugget box, which I’m really hoping is intended for groups of people and not just one person!)
When I go into the code for the task, I see this (comments removed to reduce space):
ods graphics / reset imagemap; proc sgplot data=work.importl scatter x=Sodium y=Total_Fat / group=Category transparency=0.0 name=’Scatter’; xaxis grid; yaxis grid; run; ods graphics / reset;
I copy that code, then I open up the Snippet under “Data” called “Generate PowerPoint Slide." I leave the top portion (of course, you can change the TITLE and FOOTNOTE) and highlight over the part that reads:
title 'Horsepower by Type and Origin'; proc sgplot data=sashelp.cars; dot type / response=horsepower limits=both stat=mean markerattrs=(symbol=circlefilled size=9); xaxis grid; yaxis display=(nolabel) offsetmin=0.1; keylegend / location=inside position=topright across=1; run;
I replace that with the code from the Scatterplot task. When I run the Snippet, I get prompted to open the downloaded file (this will vary based on operating system and browser you’re using) and then I open the newly created PowerPoint file.
You may notice that some of the markers and fonts have changed from when we saw the scatterplot in SAS University Edition; I’m looking into why this happened, but hoping someone here knows.
Although PowerPoint is great, it’s not your only option. When you have your graph open, at the top left corner are a couple of buttons. They are, in order, Export to HTML, Export to PDF, and Export to Word (as an RTF).
Here’s the output in Word (note the colour change of the markers):
And the PDF (the same as what we’re seeing in SAS University Edition):
SAS University Edition makes it very easy to export your tables and graphs to whatever format you need – whether it’s for a presentation, a report, or to send to someone for their review, with a couple of clicks you’ll be all set.
Did you find something else interesting in this data? Share in the comments. I’m glad to answer any questions.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.