The script begins by creating a 'plantProd' dataset containing production data for different sites and periods. A trick is used to create breaks in the X-axis of the graph: points in the 'Time' variable are replaced by non-breaking spaces. Then, a PROC TEMPLATE procedure defines a custom graph template ('chunked') that superimposes a bar chart (BarChartParm) and a series plot (SeriesPlot). Finally, PROC SGRENDER uses this template and the data to generate the final chart, demonstrating how to visually separate groups of categories on a discrete axis.
Data Analysis
Type : INTERNAL_CREATION
The data is created directly within the SAS script via a DATA STEP and the DATALINES statement.
1 Code Block
DATA STEP Data
Explanation : This DATA STEP block creates the 'plantProd' table. It reads raw data via 'datalines', defines variable attributes (labels, formats), and replaces periods in the 'Time' variable with non-breaking spaces ('A0'x). This substitution is a technique to force spacing on a discrete axis in an SG graph.
Time=translate(Time,  ., '.'); /* map '.' to non-breaking space */
8
DATALINES;
9
3210.0334 w01 US64
10
3730.0173 w01 CA41
11
2180.0367 w08 US64
12
4200.0188 w08 CA41
13
1170.0163 w16 US64
14
4610.0190 w16 CA41
15
640.0441 w24 US64
16
3200.0208 w24 CA41
17
1560.0261 w32 US64
18
6200.0116 w32 CA41
19
1150.0193 w40 US64
20
7000.0058 w40 CA41
21
1100.0091 w48 US64
22
6420.0039 w48 CA41
23
1570.0099 w52 US64
24
5860.0012 w52 CA41
25
. . .. US64
26
. . .. CA41
27
46570.0315 Q1 US64
28
24910.0162 Q1 CA41
29
14340.0251 Q2 US64
30
21470.0112 Q2 CA41
31
16960.0314 Q3 US64
32
32060.0155 Q3 CA41
33
28950.0399 Q4 US64
34
41740.0226 Q4 CA41
35
. . ... US64
36
. . ... CA41
37
60910.0294 H1 US64
38
46380.0145 H1 CA41
39
45910.0364 H2 US64
40
73800.0197 H2 CA41
41
;
42
RUN;
2 Code Block
PROC TEMPLATE
Explanation : This block defines a statistical graph template named 'chunked' using PROC TEMPLATE. The template superimposes a bar chart (BarChartParm) and a series plot (SeriesPlot). The X-axis is configured as 'discrete' to treat each 'Time' value as a distinct category. The secondary Y-axis (Y2) is used for the percentage curve.
Explanation : This procedure executes the rendering of the graph. It applies the 'chunked' template (defined previously) to the 'plantProd' dataset to generate the final graph, which will show production by site and period with visual breaks.
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.