We’re smarter together. Learn from this collection of community knowledge and add your expertise.

How to get started with SAS University Edition - Part 5

by Super Contributor on ‎02-21-2015 11:39 AM - edited on ‎10-05-2015 03:10 PM by Community Manager (1,041 Views)

Tasks – Graph

In my first post, I covered the Data Tasks which include data management and quality.  The tasks included Characterize, List, Rank, Random, Sort, Table, and Transpose Data.  In this post, I will review the Graph Tasks in the same way I did the data ones – Data, Options, and if relevant, a screen shot of the results. As mentioned in the section on Data Tasks, using SAS UE is an ideal way to learn about specific PROCs as the code is automatically generated, allowing for it to be reviewed, edited, and tested.


Bar Chart

The ubiquitous bar chart is easy enough to create in SAS; but having it created by dropboxes and checkboxes makes it even easier to create them.


In the screenshot below, you can see that the only required fields are DATA and CATEGORY. I’ve filled in the other variables, for demonstration purposes.



The next two screen shots are the options (of which there are a lot) and they are shown in the default.  I won’t go through them, but wanted to show them here so you could see that they are all the options available through PROC SGPLOT (which is used in the auto-generated code by SAS UE).

Pt_5_image_2a.png     Pt_5_image_2b.png


Bar-Line Chart

The bar-line chart is not significantly different from the bar chart.  Here is the information I’ve supplied, where the only differences are the Line Response variable and the label for the Bar Response variable.



The options are also similar, and nothing that is of a surprise.  These are the same options that are available through base SAS, and another opportunity for SAS users to learn what options are available through the PROC.



Here is the output, although simplistic; I’m showing this to highlight that the line is clearly different from the bars, and the primary y-axis has light grey gridlines which can be useful.






Ah, the ubiquitous histogram – made even easier!  In three clicks, you can have a histogram made on your variable.  As with the other PROCs, the options list provides you the tools to enhance your output to all new levels.



The ability to apply a normal density curve, change the colour of the graph, and specify the number of bins all via point-and-click is fantastic.



Line Chart


Creating a line chart is just as easy as the other graphs already discussed.  A response variable is not mandatory, so you can create the graph exactly as you need to see it.




The Line Graph options is one where I’ve learned something new that I will be able to use right away, both in the PROC and through SAS University Edition.  The ability to have the Categories reversed (in this case with a simple check-box) is something I was unaware of and can think of at least 2 graphs I create at work where this will be a huge benefit.



Pie Chart


OK, I admit I am biased against pie charts.  I will fight tooth and nail not to use them, and cringe when I see them (especially exploding 3D ones).  However, they may very well serve a purpose that I am unaware of, and so to be fair, I am including them in this article.


If I haven’t mentioned it, or even if I have it bears repeating – one of the fantastic features within the SAS graphics interfaces (ODS Graphics Designer, Graph’n’Go, SAS University Edition) is that if you are creating a graph that has a response variable, the only variables available in that drop box are those that can be used as a response variable.  This makes your graphs at least logical in the sense that you won’t have SAS trying to put a categorical variable as a response.  You’re graph may still be nonsensical (graphing flip flop colours by airplane wing span) but at least it will technically be right.


Here’s the data tab for the creation of a pie chart.



The list of options; at least 3D and exploding aren’t options here.



Scatter Plot


I may sound like Sheldon Cooper (from TV’s The Big Bang Theory) when I say this, but Scatter Plots are my second favourite analytical graph (my first are Survival / Time-to-Event analyses).


Specifying the X and Y variables are the only requirements, and the Options (next screen shot) are standard options for a scatter plot.





Series Plot


The series plot is, from my experience, the most under-utilised of the analytical graphs. From what I’ve seen, histograms, pie charts, and tables are used more frequently.  This is unfortunate because the data has a story to tell, and if a graph / analytical method is used that doesn’t tease the details out, you could be missing some really important information.


This would be particularly unfortunate if you are using SAS University Edition, as it is just as easy to create a series plot as it is to create the other types of graphs; all that is needed is an understanding of the data and the question you are trying to answer.  Selecting your X and Y variable, and clicking run – that’s all you need to create the series plot.





The Options which can be modified:



For this graph I wanted to show the output to highlight a couple of nice aids SAS University Edition provides automatically.  You’ll notice on the X axis the year is only provided at the (0, 02Mar2009) point.  This makes for a more organized X-axis.  The colours selected as a default are all very distinct, but not clashing or visually jarring (as can be found in graphs created by other software).  Finally, the Legend is alphabetized, which I really like. I find searching for a particular category can, if the Legend is not sorted in this way, difficult – I feel spending more than 2 seconds looking for the category of interest is too long. Alphabetical sorting makes this a quick and easy task.




Simple HBar


The last (I know, I’m sad that this article is coming to an end as well!) graph is the Simple Horizontal Bar chart.  This is another graph that I feel has a purpose, but because of a lack of understanding by many who create graphs, is not used enough.   One of the significant benefits to this version of the bar chart is the labels on the x-axis are moved to the y-axis, allowing for longer labels to be easily read (rather than putting the text on a slant, squishing it beyond legibility, or shortening it to something unrecognizable).


Here’s the screen shot for the Data tab; I’ve neglected to mention until now that another feature, which may be a small thing but I find it to be useful at times, are the different icons for indicating what type of data is in the variable.   Although SAS University Edition won’t let you put in an incorrect data type into one of the variables (as previously mentioned), I like knowing that this metadata is readily available.




Here is the Options tab; clustered or stacked, mean or sum, reverse order, all are useful in certain types of graphs and having them right in front of you makes it so much easier to generate effective graphs.



Finally, here is the output; clean, easily readable and exactly what I needed.



The simplicity of SAS University Edition allows for both new and experienced SAS Users, from all disciplines and fields, to generate high quality graphs without writing code.  Obviously point-and-click creation of a graph is not a replacement but rather a supplement to good understanding of analysis, graphs, and, most importantly, your data. However, having the tools available in this way will hopefully mean more people will explore these types of graphs and feel more at ease using SAS, leading to better storytelling and analysis.




This is article #5 in a six-part series. Links to all of them are below:


by New Contributor tepposaari
on ‎09-12-2017 05:34 PM

Where can I find those options tabs that can be seen in the images? My version does not show any option tabs, it just pastes the code for HBar or other snippets: http://i.imgur.com/slTVSNj.png

Your turn
Sign In!

Want to write an article? Sign in with your profile.

Looking for the Ask the Expert series? Find it in its new home: communities.sas.com/askexpert.