Hi All,
Is it possible to re-create this chart in SAS. It was made in Excel. I need to incorporate drill down and some other things but can't do it in Excel. I have looked around in the docs, but did not see anything like this. Oh by the way need the spaces between groups. The groupa are from left to right: weeks, quarters, half years. I appreciate the help. I am running SAS 9.2 on windows.
Thanks.
Here is your graph using SAS 9.2 SGPLOT procedure.
SAS 9.2 SGPLOT Code is straightforward:
ods html;
ods graphics / reset imagemap=on;
title 'Stacked Grouped BarLine Chart';
proc sgplot data=groupedData;
format xaxis $xaxis. linevalue percent.;
vbar xaxis / response=BarValue group=Group missing url=url;
vline xaxis / response=LineValue group=Group missing y2axis break markers
markerattrs=(symbol=circlefilled size=5) lineattrs=(pattern=solid);
xaxis display=(noticks nolabel) discreteorder=data;
yaxis offsetmin=0 values=(0 to 14000 by 2000) grid;
y2axis offsetmin=0 values=(0 to 0.07 by 0.01);
run;
ods html close;
The key is how to create the blank spaces between the groups. Using a missing value or blank works if you have only one. With two, they get combined into one value on the x axis. So, I replaced the two missing values in your spreadsheet with the strings "Miss1" and "Miss2". You can use any distinct strings.
Then, I created a format and formatted each of these strings to a unique invisible string using the non-breaking space 'A0'x. This space does not get stripped out, and so I made one with a nbsp on each side of a 10 character string, and another with a third nbsp in the middle.
I also changed your structure from a multi column to a grouped format mainly to get the stacked bar chart. VLINE statement uses BREAK option to break each line at the missing value. Add URL column to data set and set it on the url option.
Message was edited by: Sanjay Matange Files attached.
I believe this could be made using 9.2 SG or GTL. Can you attach your data?
Dear
I suppose with many customization you can use this sample provided by SAS :
http://support.sas.com/documentation/cdl/en/graphref/63022/HTML/default/viewer.htm#a003171144.htm
I depend also which SAS tool you use (EG,Add-ins, SAS Foundation, SAS graph, Web Report Studio ) ?
Regards
Hi lacrefa,
Thanks for the link. I am aware of the vast standard charting capabilities of SAS, and I do not know how to put spaces in the xaxis using gbarline, there is not option for grouping. I am not a new SAS programmer, but SG and GTL I am not familiar with it at all.
Thanks,
CPAZ
Hi Sanjay@SAS. Thanks. I have attached the data.
Thanks for any help you can provide.
Here is your graph using SAS 9.2 SGPLOT procedure.
SAS 9.2 SGPLOT Code is straightforward:
ods html;
ods graphics / reset imagemap=on;
title 'Stacked Grouped BarLine Chart';
proc sgplot data=groupedData;
format xaxis $xaxis. linevalue percent.;
vbar xaxis / response=BarValue group=Group missing url=url;
vline xaxis / response=LineValue group=Group missing y2axis break markers
markerattrs=(symbol=circlefilled size=5) lineattrs=(pattern=solid);
xaxis display=(noticks nolabel) discreteorder=data;
yaxis offsetmin=0 values=(0 to 14000 by 2000) grid;
y2axis offsetmin=0 values=(0 to 0.07 by 0.01);
run;
ods html close;
The key is how to create the blank spaces between the groups. Using a missing value or blank works if you have only one. With two, they get combined into one value on the x axis. So, I replaced the two missing values in your spreadsheet with the strings "Miss1" and "Miss2". You can use any distinct strings.
Then, I created a format and formatted each of these strings to a unique invisible string using the non-breaking space 'A0'x. This space does not get stripped out, and so I made one with a nbsp on each side of a 10 character string, and another with a third nbsp in the middle.
I also changed your structure from a multi column to a grouped format mainly to get the stacked bar chart. VLINE statement uses BREAK option to break each line at the missing value. Add URL column to data set and set it on the url option.
Message was edited by: Sanjay Matange Files attached.
Hi Sanjay,
You need to use the "advanced editor" to attach file. Would you also please attach the sas dataset?
Thanks!
How do I signify this post has been answered?
A couple of buttons labelled something like "Useful Reply" and Correct Answer" should appear at the bottom of each new post; all you should then need to do is click the relevant one - but having said that, I'm not seeing them here, and I don't know why not. Can anybody help?
Hi,
The "helpful answer" and "correct answer" buttons are only available to the Original Poster after login.
Hello Sunjay,
I did as your instruction. But i strugged on Error transcode as picutre below.
And i try to use another Non-space-breaking but it's not work.
Would you mind to suggest?
CPAZ;
It's a too busy graph and dual scale graphs are not good dataviz practice. I recommend that you split it into two smaller graphs - one for count and another for percent. Retain the same colours in both graphs for each group to reduce the amount of legend and use fewer tick marks on the axes to reduce the busyness.
Hi Bill,
Thanks for the reply. Unfortunately separating the graphs is not an option. This kind of graph is commonly used in my company, so the audience is well aware on how to read the graph. It gives them the most amount of information in a single graph.
CPAZ
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: