BookmarkSubscribeRSS Feed
GPatel
Pyrite | Level 9

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

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

6 REPLIES 6
Reeza
Super User

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:

http://robslink.com/SAS/Home.htm

https://support.sas.com/sassamples/graphgallery/

 

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

GPatel
Pyrite | Level 9
I m using SAS 6.1 EG.
Jay54
Meteorite | Level 14

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;

  run;

 

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

ChrisHemedinger
Community Manager

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.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
GPatel
Pyrite | Level 9

.

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.....

 

 

  RAW_DATA              
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
                 
  Reshape_Data              
  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          
                 
Jay54
Meteorite | Level 14

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;
run;

 

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

 

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

 

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1239 views
  • 1 like
  • 4 in conversation