The code first defines a `STATGRAPH` named 'selections' using `PROC TEMPLATE`. This template uses two dynamic variables, `upLimit` and `lowLimit`, to filter vehicles. The graph is a `layout lattice` with two cells, each containing a `scatterPlot`. The first cell displays vehicles with highway MPG greater than or equal to `upLimit`, while the second displays those with MPG less than or equal to `lowLimit`. The template is then rendered via `PROC SGRENDER`, using the `sashelp.cars` data and specifying values for `upLimit` (44) and `lowLimit` (16).
Data Analysis
Type : SASHELP
The script uses the internal `sashelp.cars` dataset, available by default in all SAS installations, to retrieve vehicle information (model, MSRP, highway MPG).
1 Code Block
PROC TEMPLATE
Explanation : This block defines a reusable graph template named 'selections' using the `PROC TEMPLATE` procedure. It incorporates dynamic variables `upLimit` and `lowLimit` which will be used to filter the displayed data. The graph is structured as a two-row lattice arrangement, each presenting a scatter plot (`scatterPlot`). The first row visualizes vehicles whose highway consumption is greater than or equal to `upLimit`, while the second shows those whose consumption is less than or equal to `lowLimit`. Data point labels display the vehicle model.
Explanation : This block configures the ODS Graphics system for graph output, resetting parameters and defining the height. Then, `PROC SGRENDER` is used to render the 'selections' graph template previously defined. It uses the `sashelp.cars` dataset as the source and assigns specific values (44 for `upLimit` and 16 for `lowLimit`) to the template's dynamic variables. This generates an ODS graph that highlights vehicles with exceptionally high or low highway fuel consumption.
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.