Data visualization with SAS programming

Custom Graph

Posts: 62

Custom Graph

How can I create a custom graph shown in an attached Excel file ?

Sample data and custom graph is shown in an attached file.

Grand Advisor
Posts: 16,420

Re: Custom Graph

3D plots are not really useful in terms of data visualization, I would recommend using a flat bar chart instead. In a 3D chart, it's hard to line up the top of the bar to the axis to determine what the values are. 


You'll need to code for this type of graph, since I don't think you can do it through the point and click interface.

I would recommend GTL, though SGPLOT has some good options.


What version of SAS are you on? Graphing options are changing very quickly in the last few years/releases.


You can find sample graphs here, with data and code:


I'll move your post to the graphics forum so some of the graph guru's can help. 

Posts: 62

Re: Custom Graph

I m using SAS 6.1 EG.
Posts: 1,044

Re: Custom Graph

[ Edited ]

It will be easier if you change your data where "Flags_A", "Flags_B", etc are in a category column, the "Yes" and "No" are group values for each category and the value is in a "Value" column.  Then, you can use SGPLOT with one VBAR statement with a GROUP option.  We need to know the SAS version you are using, in addition to the EG version. 


  proc sgplot data=data;

    vbar category / response=value group=group dataskin=pressed;



Dataskin=pressed will give you a cylindrical look, You can customize further with other options.  See product documentation.

Community Manager
Posts: 2,607

Re: Custom Graph

From your example, it looks like you shared a SAS Report that you build in EG (SRX output) -- using either the List Data wizard or Summary Tables task, so I imagine your source data is "flatter" than what you're showing with the across columns.  If you shared your raw data, it would be easier to share exact code that could reproduct the chart you want.

Posts: 62

Re: Custom Graph - Resh


The output I shared yesterday was resulting data from proc tabulate procedure.

Below is Raw_Data and I want to reshape the data as shown below.


Then I can used proc gchart.....



Obs Flag_A Flag_B Flag_C Flag_D Flag_E Flag_F Flag_G N
1 No             1
2 Yes             2
3   No           3
4     No         4
5     Yes         5
6       No       6
7       Yes       7
8         No     8
9         Yes     9
10           No   10
11           Yes   11
12             No 12
13             Yes 13
  Flag_A No 1          
  Flag_A Yes 2          
  Flag_B No 3          
  Flag_B Yes 0          
  Flag_c No 4          
  Flag_c Yes 5          
  Flag_d No 6          
  Flag_D Yes 7          
  Flag_E No 8          
  Flag_E Yes 9          
  Flag_F No 10          
  Flag_F Yes 11          
  Flag_G No 12          
  Flag_G Yes 13          
Posts: 1,044

Re: Custom Graph - Resh

I cleaned out your xls file, keeping only the reshaped data and one sheet and added column headers.

Here is GCHART and SGPLOT code.


proc import datafile='C:\Reshape_Data.xlsx'
  dbms=XLSX out=ExcelData replace;


proc gchart data=ExcelData;
  vbar group / sumvar=value group=cat;


proc sgplot data=ExcelData;
  vbar cat / response=value group=group groupdisplay=cluster dataskin=pressed;
  yaxis integer;



Post a Question
Discussion Stats
  • 6 replies
  • 1 like
  • 4 in conversation