It might snow this weekend here at the SAS headquarters! This would be the first snow of the season for us, and it got me thinking about snow. Apparently these thoughts have manifested themselves in my computer graphics work ... in the form of a snow animation. Follow along, and [...]
Find out how to kick-start your volunteering and leadership skills at SAS Global Forum.
The post Take your leadership skills to the next level at SAS Global Forum appeared first on SAS Learning Post.
In this blog series, we’ve spoken directly to professors to find out why it’s so important to teach analytics, their advice for students, and to learn how they create interest in analytics programs at their universities. For this third and final post, we’ll hear how SAS has played a role [...]
Two professors’ perspectives on SAS and the future of analytics was published on SAS Voices by Georgia Mariani
When a Visual Analytics 8.3 report moves on a screen from one page to the next – all by itself, without a human hovering over a keyboard – you're seeing the Report Playback feature of SAS Visual Analytics Viewer 8.3 in action.
Reasons for using visual movement
Playable dashboards are easy to create and use. But let's ponder for a moment: Why would you want to set your report in motion? You might want it to scroll automatically:
- At a kiosk or booth where folks linger for short periods of time.
- During a presentation to an audience so you're hands-free. You decide how long each page displays and are free to focus on explaining key facts and figures in the moving report without the distraction of manually flipping through each page. Sort of like your car's cruise control – you take your foot off the pedal and the vehicle keeps going.
Design considerations for playable dashboards
If the intent is to let the report run on its own in a kiosk or a booth, be mindful that such environments require information to move fast. Those watching the playable dashboard expect to grasp key facts and figures quickly. Time is of the essence.
A short attention span benefits from a report design whereby each report page contains one report object that quickly conveys the essence of the message in a few seconds. If you use a complex report design with multiple report objects and a small font, chances aren't good that your audience will absorb meaning from your report.
Any report object (for example, scatter plot) that requires your user to first look at the legend and then comprehend the data in the graph would be unsuitable for playable dashboards that are set to move at a fast rate, such as three or four seconds per page.
Example of a playable dashboard
I designed a report to illustrate carbon dioxide (CO2) emissions for 20 countries. I added five report objects that are easy to comprehend in about five seconds (a subjective estimate, of course.) I also added a scatter plot and geomap with legends that are challenging to comprehend to illustrate why report objects with legends can be unsuitable for a playable dashboard!
For the scatter plot, the presenter would have to expand the legend tooltip to show the legends for the country data in that report object – not realistic in a fast-paced dashboard. In the geomap, the audience needs to look at the legends at the bottom (icons, colors, etc.) and associate that legend with the display in the graph. That’s a lot of brain activity for five seconds – unrealistic. It makes sense, then, to use report objects here that don’t depend on user comprehension of legends to understand the data.
Let the show begin!
When the scatter plot or geomap is displayed, notice how it’s hard to comprehend such report objects in five seconds. In such a short timeframe, it's impossible to process legends and the data, all at once.
How to Create a Playable Dashboard in the Web-based Viewer
- In SAS Visual Analytics Viewer, I opened the report and chose Edit playback from the main menu.
- In the Edit Playback dialog, I chose the following options:
a. Transition unit – I can choose to display one page at a time or one object at a time. I chose to display one page at a time.
b. Seconds per unit – I chose to display each page for five seconds.
c. Show canvas only – I chose this option because it hides the report control area, page tabs, and page controls for a nicer look.
d. Show timer – This option would display a countdown for each page or object transition. I did not choose this option.
e. Show navigation controls for the report playback – I chose this option because it displays navigation controls in the bottom right corner of the viewer when I hover over the report with my mouse. Personally, I really like this feature because it gives me the flexibility to intervene and move the report pages forward or backward, pause the playback, or exit the playback.
Finally, I save and exit, and the playable dashboard begins to play on my monitor screen.SAS® Visual Analytics on SAS® Viya® Try it for free!
How to create a playable dashboard with SAS Visual Analytics was published on SAS Users.
Did you ever try to find articles about a topic in a library before computers came along? You might have had to manually look through several hundred bound periodicals, or perhaps you were lucky enough to find the topic in a master index that pointed you directly to the year [...]
The post How to find SAS blog posts about your favorite topics appeared first on SAS Learning Post.
When a graph includes several markers or line styles, it is often useful to create a legend that explains the relationship between the data and the symbols, color, and line styles in the graph. The SGPLOT procedure does a good job of automatically creating and placing a legend for most graphs. However, sometimes it is useful to override the procedure's default choices. This article describes five tips that you can use to customize the content and placement of legends. The tips are:
- Suppress the legend by using the NOAUTOLEGEND option.
- Choose which components of the graph appear in the legend by using a KEYLEGEND statement and the NAME= option.
- Position the legend by using the LOCATION= and POSITION= option on the KEYLEGEND statement.
- Exclude one or more items from a legend by using the EXCLUDE= option on the KEYLEGEND statement (requires SAS 9.4M3).
- Consolidate one or more items by using the LEGENDITEM statement (requires SAS 9.4M5).
1. Suppress the legend
By default, the SGPLOT procedure displays a legend when there are multiple plots that are overlaid in the graph. This can be caused by multiple statements or by using the GROUP= option on a statement. If the information in the default legend is redundant, and you might want to suppress it. For example, the following legend is unnecessary because the title explains the data and the regression line. You can uncomment the NOAUTOLEGEND option to suppress the legend.
title "Linear Regression for Weight and Height"; title2 "The legend is unnecessary"; proc sgplot data=Sashelp.Class /* NOAUTOLEGEND */; scatter x=Height y=Weight; reg x=Height y=Weight / nomarkers; footnote J=L "Use the NOAUTOLEGEND option to suppress the legend"; run; footnote;
2. Choose which components appear in the legend
In some graphs that overlay multiple components, some components are self -explanatory and do not need to appear in the legend. You can choose which components appear in the legend by using the NAME= option on the statements and using the KEYLEGEND statement to specify the contents of the legend. For example, the following statements create a graph that consists of a scatter plot, a confidence ellipse, and a regression line. If you only want the confidence ellipse and regression line to appear in the legend, use the NAME= option to identify each component and use the KEYLEGEND statement to specify the contents of the legend:
title "Weight versus Height"; title2 "Overlay Least Squares Fit and Confidence Ellipse"; proc sgplot data=Sashelp.Class; scatter x=Height y=Weight / name="scatter"; ellipse x=Height y=Weight / name="ellipse"; reg x=Height y=Weight / name="reg" nomarkers lineattrs=GraphData2; keylegend "reg" "ellipse"; /* list item in the order you want them */ run;
3. Position the legend
The KEYLEGEND statement supports the LOCATION= and POSTITION= options, which enable you to place the legend almost anywhere in the graph. The LOCATION= option controls whether the legend appears inside or outside of the graph area. The POSITION= option controls the placement of the legend on the graph (left, right, top, bottom,...). However, I can never remember which option controls which attribute! Therefore, I created a mnemonic, which I hope will help you remember, too:
- The LOCATION= option contains the substring 'CAT'. A CAT likes to go INSIDE and OUTSIDE the house. Therefore, the valid keywords for the LOCATION= option are INSIDE and OUTSIDE.
- The POSITION= option contains the substring 'SIT'. You can SIT on the LEFT or RIGHT side of a couch. (Also, "position" can be used as a verb to mean "place on a page.") Therefore, the valid keywords for the POSITION= option are BOTTOM, BOTTOMLEFT, BOTTOMRIGHT, LEFT, RIGHT, TOP, TOPLEFT, and TOPRIGHT. (Some other graphical elements support a CENTER position, but not the legend.)
The following graph is the same as in the previous example, except that the location of the legend is inside the graph area and the position of the legend is in the lower-right corner. When you move the legend to the left or right side of the graph, it is often useful to use the ACROSS=1 option to force the legend to list the items vertically. Similarly, if you position the legend at the top or bottom of a graph, you might want to use the DOWN=1 option to list the items horizontally.
keylegend "reg" "ellipse" / location=inside position=bottomright across=1;
4. Exclude items from a legend
When you use the GROUP= option to display groups, you might want to exclude some of the group categories from the legend. The KEYLEGEND statement supports the EXCLUDE= option that you can use to exclude certain items. Three situations come to mind:
- The group levels contain missing values. You might want to exclude the missing values from the legend by using KEYLEGEND / EXCLUDE=(" ");.
- The purpose of the graph is to focus on one or two subgroups. If so, it might make sense to label only those groups. For example, if the purpose of a graph is to show income disparity between blacks and whites, you might decide not to include Asians or Hispanics in the legend: EXCLUDE=("Asian" "Hispanic");.
- The group is binary. If a graph shows the results of a clinical trial and the legend includes the marker shape for the patients who died, it should be clear that the other marker shape represents patients who survived: EXCLUDE=("Alive");. An example is shown below
ods graphics / attrpriority=none; title "Patient Status"; proc sgplot data=Sashelp.Heart(obs=200 where=(Systolic<=200)); styleattrs datasymbols=(X CircleFilled); scatter x=Systolic y=Diastolic / group=Status; keylegend / exclude=("Alive"); run;
5. Customize items in a legend
The previous section shows how to exclude one or more levels in a categorical variable that is specified on the GROUP= option. You also might want to customize the items that appear in the legend in order to combine, for example, marker and line attributes. A situation where this comes up is when you want to overlay a group of curves on a scatter plot.The LEGENDITEM statement (supported in SAS 9.4M5) enables you to specify what combination of markers and line patterns you want to appear for every item in a legend. It is a "super customization" statement that gives you complete control over the legend items.
The following statements show how to use the LEGENDITEM statement to create a customized legend. By default, if you use the REG statement with the GROUP= option, the legend will show only the colors and line patterns for the regression lines. In the following example, I have used the ATTRPRIORITY=NONE option to force the marker symbols to differ between groups. I want the legend to show not only the colors and patterns of the regression lines but also the marker symbols for each group:
/* ensure order of BP_Status is High, Normal, Optimal */ proc sort data=Sashelp.Heart(obs=200 where=(Systolic<=200)) out=Heart; by BP_Status; run; ods graphics / attrpriority=none; title "Patients by Blood Pressure Status"; proc sgplot data=Heart; styleattrs datalinepatterns=(solid) ; reg x=Systolic y=Diastolic / group=BP_Status; legenditem type=markerline name="H" / label="High" lineattrs=GraphData1 markerattrs=GraphData1; legenditem type=markerline name="N" / label="Normal" lineattrs=GraphData2 markerattrs=GraphData2; legenditem type=markerline name="O" / label="Optimal" lineattrs=GraphData3 markerattrs=GraphData3; keylegend "O" "N" "H" / title="BP Status"; run;
In summary, PROC SGPLOT in SAS supports several ways to create, suppress, position, and customize the items in a legend. Do you have a favorite way to customize a legend in PROC SGPLOT? Leave a comment!
The post 5 tips for customizing legends in PROC SGPLOT in SAS appeared first on The DO Loop.