10-24-2012 04:00 PM
Hello, I've created a report that runs data for ~50 different entities and generates tables/graphs for each into its own pdf that's then being emailed via SAS. One type of graph has given me problems:
I've created a table - let's say overall performance - that has every entity and a score from 0-100 in it. This is plotted into a bar chart in ascending order. What I'd like to do is highlight one bar in the chart each time it's generated so that each entity can quickly approximate where their performance lies in relation to their peers (see attached).
Any ideas? It's appreciated. I've been trying various things and searching for days but overlay/highlight are too broad of terms to find my answer. I'm an advanced user running SAS 9.2.
10-24-2012 06:42 PM
Some code how you are generating the charts might help to address specific options
The general approach is to assign a categorical variable that is assigned one value for your entity and another value for all others. The syntax to get the color change will change depending on the proc used. You will likely also want to suppress the default legend unless you find it helpful.
10-25-2012 08:19 AM
Here is one way to do it with gchart ...
data my_data; set sashelp.class;
if name='Alfred' then hilight='Y';
axis1 label=none value=(angle=90);
pattern1 v=solid c=blue;
pattern2 v=solid c=red;
proc gchart data=my_data;
vbar name / type=sum sumvar=weight descending
subgroup=hilight nolegend maxis=axis1 raxis=axis2;
10-25-2012 11:24 AM
Right, so you (the original poster) might want to make use of a macro variable in the data step to dynamically change the value that gets used to flag the highlight column.
Presumeably, you are already doing some kind of macro to loop through your 50+ entities.
Say you are looping through store names, and have a macro variable called ThisStore for the current store name.
Data my_data ;
set StoreSales ;
if storeName = "&ThisStore" then hilight='Y' ;
else hilight='N' ;
(Note the use of double-quotes when using a macro variable to substitute in a character variable value.)
11-01-2012 02:36 PM
Thanks for the help folks! Since this is 2012 I'm using proc template and sgrender to create my graphs rather than gchart but the same ideas apply =P. I never even considered creating another field to do the graph as I was convinced there was a more elegant approach. I ended up creating a new field for highlighting like this
if entity=¯oentity then hilight=performance;
And then overlaid that on top of the full chart containing every entity (using barchart command in proc template). It has to recreate the table every iteration - not ideal - but it works fine with some sleep pauses and gives me something else to point to when lobbying for an improved machine =). Thanks again