Published on :
Chart CREATION_INTERNE

Bubble Chart with Transparency

This code is also available in: Deutsch Español Français
Awaiting validation
This SAS© script uses PROC SGPLOT to create a bubble chart. Data is defined inline via a DATA STEP. The output is generated in HTML with a PNG image of the chart, including bubbles with a defined transparency level and custom styles for colors and axes.
Data Analysis

Type : CREATION_INTERNE


The data (`my_data`) is created directly in the SAS script via a DATA STEP and the DATALINES command.

1 Code Block
DATA STEP Data
Explanation :
This DATA STEP block creates the `my_data` dataset with `series`, `x`, `y`, and `value` variables. Values are provided directly in the script via the `datalines` statement. This dataset will be used as the source for the SGPLOT chart.
Copied!
1DATA my_data;
2LENGTH color $ 8;
3INPUT series $ 1-1 x y value;
4DATALINES;
5A 1.0 1.0 .65
6A 2.0 0.9 0.3
7B 1.4 2.3 .65
8B 2.2 1.4 0.3
9;
10RUN;
2 Code Block
PROC SGPLOT
Explanation :
This block configures the ODS output to generate an HTML file (`bub3.htm`) containing the chart. `ods graphics` specifies the PNG format and image dimensions. `title1` defines the main chart title. `PROC SGPLOT` is used to create a bubble chart (`bubble`). Bubbles are plotted based on `x` and `y`, their size is proportional to `value`, and they are grouped by `series`. Bubble transparency is set to 50% (`transparency=.5`). Color and axis styles are also customized.
Copied!
1ODS LISTING CLOSE;
2ODS HTML path=odsout body="&name..htm"
3 (title="SGplot Bubble with Transparency")
4 style=htmlblue;
5 
6ods graphics / imagefmt=png imagename="&name"
7 width=800px height=600px noborder imagemap;
8 
9title1 color=gray33 ls=0.0 h=23pt "Transparent Bubbles";
10 
11PROC SGPLOT DATA=my_data aspect=1 noautolegend;
12styleattrs datacolors=(cx9999ff cx993366);
13bubble x=x y=y size=value / group=series proportional
14 bradiusmax=70px lineattrs=(color=gray33) transparency=.5;
15yaxis
16 values=(0 to 3 BY 1) label='Y Axis'
17 labelattrs=(size=16pt weight=bold color=gray33)
18 valueattrs=(size=16pt weight=bold color=gray33)
19 offsetmin=0 offsetmax=0 grid minor minorcount=1;
20xaxis
21 values=(0 to 3 BY 1) label='X Axis'
22 labelattrs=(size=16pt weight=bold color=gray33)
23 valueattrs=(size=16pt weight=bold color=gray33)
24 offsetmin=0 offsetmax=0 grid minor minorcount=1;
25RUN;
26 
27QUIT;
28ODS HTML CLOSE;
29ODS LISTING;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.