The script initializes a macro variable 'name' used for the output file name. It creates a dataset 'my_data' using in-line data (`datalines`), which allows the script to be self-contained. The Output Delivery System (ODS) is configured to close LISTING output and open HTML output, specifying the output directory ('odsout') and the HTML file name. ODS graphic options are set to generate a PNG image with specific dimensions and an imagemap. Custom titles are added to the chart. The PROC SGPLOT procedure is then used to create a grouped bar chart ('vbar') where the Y-axis represents the amount ('AMOUNT') and the X-axis represents the 'CATEGORY', grouped by 'SERIES'. The 'dataskin=sheen' attribute gives the bars a 3D effect. Bar colors, axis label attributes, and the grid are also customized. After chart generation, the HTML output is closed, and LISTING output is reopened.
Data Analysis
Type : CREATION_INTERNE
The 'my_data' dataset is entirely created within the script using a DATA STEP instruction with embedded data via 'datalines'. This ensures the script's independence from external data sources.
1 Code Block
DATA STEP Data
Explanation : This DATA STEP block creates the 'my_data' dataset from data provided directly within the script (datalines). It defines three variables: 'CATEGORY' (numeric), 'SERIES' (character string), and 'AMOUNT' (numeric).
Copied!
data my_data;
input CATEGORY SERIES $ 3-11 AMOUNT;
datalines;
1 Series A 5
2 Series A 7.8
1 Series B 9.5
2 Series B 5.9
;
run;
1
DATA my_data;
2
INPUT CATEGORY SERIES $ 3-11 AMOUNT;
3
DATALINES;
4
1 Series A 5
5
2 Series A 7.8
6
1 Series B 9.5
7
2 Series B 5.9
8
;
9
RUN;
2 Code Block
PROC SGPLOT
Explanation : This block handles report generation and visualization. It configures the ODS system to produce HTML output with the chart. PROC SGPLOT is used to create a grouped bar chart (vbar) based on the 'my_data' dataset. Options include custom data colors, grouping by 'SERIES', a 3D effect ('dataskin=sheen'), and detailed axis and title customizations for better visual presentation.
title2 color=gray33 ls=0.5 h=17pt "With 3D Shading";
11
12
PROC SGPLOTDATA=my_data noautolegend;
13
styleattrs datacolors=(cx9999ff cx993366);
14
vbar category / response=amount stat=sum
15
group=series groupdisplay=cluster
16
dataskin=sheen /* <--- basically, added this line! */
17
outlineattrs=(color=black) nostatlabel;
18
yaxis
19
values=(0 to 10BY2)
20
labelattrs=(size=16pt weight=bold color=gray33)
21
valueattrs=(size=16pt weight=bold color=gray33)
22
offsetmax=0 grid minor minorcount=1;
23
xaxis
24
labelattrs=(size=16pt weight=bold color=gray33)
25
valueattrs=(size=16pt weight=bold color=gray33)
26
labelpos=right;
27
RUN;
28
29
QUIT;
30
ODS HTML CLOSE;
31
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.