The script uses the `cars` table from the internal `sashelp` library, a standard data source available in all SAS installations.
1 Code Block
PROC TEMPLATE
Explanation : This block defines a reusable `STATGRAPH` template named `simpleStats`. It specifies the visual elements of the graph, including a title, an overlay layout to combine graphic elements, a scatter plot (`scatterPlot`) grouped by the `type` variable, and reference lines (`referenceLine`) dynamically calculated using statistical functions (`median`, `mean`, `std`) and the `eval` function. A discrete legend is added, as well as a footnote (`entryFootnote`) that displays summarized statistics (min and max of `weight`) from the data set being rendered. This template encapsulates the graph's presentation logic without processing the data at this stage, making it reusable.
entryFootnote halign=left "Weight (in lbs) ranges from " eval(min(weight))
19
" to " eval(max(weight)) ;
20
endGraph;
21
END;
22
RUN;
2 Code Block
PROC SGRENDER
Explanation : This code block begins by resetting ODS graphics options (`ods graphics / reset;`) to ensure a clean graphics environment and avoid interference with previous settings. Then, the `PROC SGRENDER` procedure is used to generate the graph. It applies the `simpleStats` template previously defined (via `template=simpleStats`) to the data contained in the `sashelp.cars` table (via `data=sashelp.cars`). This produces the graph image with all the elements specified in the template, using the `msrp`, `mpg_highway`, `type`, and `weight` variables from the `cars` table for the final rendering.
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.