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!
data my_data;
length color $ 8;
input series $ 1-1 x y value;
datalines;
A 1.0 1.0 .65
A 2.0 0.9 0.3
B 1.4 2.3 .65
B 2.2 1.4 0.3
;
run;
1
DATA my_data;
2
LENGTH color $ 8;
3
INPUT series $ 1-1 x y value;
4
DATALINES;
5
A 1.01.0 .65
6
A 2.00.90.3
7
B 1.42.3 .65
8
B 2.21.40.3
9
;
10
RUN;
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!
ODS LISTING CLOSE;
ODS HTML path=odsout body="&name..htm"
(title="SGplot Bubble with Transparency")
style=htmlblue;
ods graphics / imagefmt=png imagename="&name"
width=800px height=600px noborder imagemap;
title1 color=gray33 ls=0.0 h=23pt "Transparent Bubbles";
proc sgplot data=my_data aspect=1 noautolegend;
styleattrs datacolors=(cx9999ff cx993366);
bubble x=x y=y size=value / group=series proportional
bradiusmax=70px lineattrs=(color=gray33) transparency=.5;
yaxis
values=(0 to 3 by 1) label='Y Axis'
labelattrs=(size=16pt weight=bold color=gray33)
valueattrs=(size=16pt weight=bold color=gray33)
offsetmin=0 offsetmax=0 grid minor minorcount=1;
xaxis
values=(0 to 3 by 1) label='X Axis'
labelattrs=(size=16pt weight=bold color=gray33)
valueattrs=(size=16pt weight=bold color=gray33)
offsetmin=0 offsetmax=0 grid minor minorcount=1;
run;
quit;
ODS HTML CLOSE;
ODS 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.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.