The script starts by defining a macro variable for the output file name and an ODS fileref. It then creates an internal dataset, `my_data`, using `datalines`. The main part of the script configures the ODS environment for generating an HTML file containing the chart. `PROC SGPLOT` is used to create a stacked bar chart, with specific styling and formatting options for axes and bar colors, including a sheen effect (dataskin=sheen) for a 3D rendering. The chart is saved in PNG format within the HTML file.
Data Analysis
Type : CREATION_INTERNE
The 'my_data' dataset is created directly within the script using a DATALINES statement.
1 Code Block
GLOBAL DECLARATION
Explanation : Defines a macro variable `name` to name the ODS output file and assigns the current working directory to the `odsout` fileref for ODS output.
Copied!
%let name=col4;
filename odsout '.';
1
%let name=col4;
2
filename odsout '.';
2 Code Block
DATA STEP Data
Explanation : Creates the `my_data` dataset using the `datalines` statement to provide data directly within the script. This dataset will be the source for the chart.
Copied!
data my_data;
input CATEGORY SERIES $ 3-11 AMOUNT;
datalines;
1 Series A 5
2 Series A 6.8
3 Series A 9.2
1 Series B 6.5
2 Series B 6.9
3 Series B 5.6
;
run;
1
DATA my_data;
2
INPUT CATEGORY SERIES $ 3-11 AMOUNT;
3
DATALINES;
4
1 Series A 5
5
2 Series A 6.8
6
3 Series A 9.2
7
1 Series B 6.5
8
2 Series B 6.9
9
3 Series B 5.6
10
;
11
RUN;
3 Code Block
PROC SGPLOT
Explanation : This section configures the ODS system to generate HTML output. It closes the default LISTING output and opens the HTML output, specifying the path and file name. `ODS GRAPHICS` options are used to define the image format (PNG), the name, and the dimensions of the graph. Two titles are defined for the graph. `PROC SGPLOT` is then called to create a stacked bar chart from the `my_data` dataset. Options include suppressing the automatic legend, padding, defining data colors, and most importantly `dataskin=sheen` for a 3D effect. The Y and X axes are configured with specific style labels and values. Finally, ODS HTML is closed, and ODS LISTING is reopened.
dataskin=sheen /* <--- basically, added this line! */
17
outlineattrs=(color=black) nostatlabel;
18
yaxis
19
values=(0 to 16BY4)
20
labelattrs=(size=16pt weight=bold color=gray33)
21
valueattrs=(size=16pt weight=bold color=gray33)
22
offsetmax=0 grid minor minorcount=3;
23
xaxis
24
labelattrs=(size=16pt weight=bold color=gray33)
25
valueattrs=(size=16pt weight=bold color=gray33)
26
display=(noticks);
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.