The script begins by configuring ODS (Output Delivery System) options for graphic output, including the image save path, format (PNG), and dimensions. It then generates a first matrix for 'sashelp.cars' vehicle data, filtering specific types. Two additional matrices are created for the 'sashelp.iris' dataset, one using the standard 'matrix' statement and the other the 'compare' statement for cross scatterplots. Each visualization includes titles, variable labels, and marker style options.
Data Analysis
Type : SASHELP
Data comes from SAS's built-in libraries, 'sashelp.cars' and 'sashelp.iris', which are available by default in the SAS environment.
1 Code Block
ODS Configuration
Explanation : This block configures the Output Delivery System (ODS) to direct graphic output to a specified path and sets graphic options such as resetting parameters, color attribute priority, border, image dimensions, image name ('matrix1'), format ('png'), and antialiasing.
Explanation : This procedure generates a scatterplot matrix for the `sashelp.cars` dataset, filtering vehicle types 'Sedan' and 'Sports'. It assigns labels to the variables 'mpg_city' and 'mpg_highway', then creates the matrix using 'mpg_city', 'mpg_highway', 'horsepower', and 'weight' with 0.5 transparency and filled circle markers.
Copied!
proc sgscatter data=sashelp.cars(where=(type in ('Sedan' 'Sports')));
title 'Scatterplot Matrix for Vehicle Type';
label mpg_city='City';
label mpg_highway='Highway';
matrix mpg_city mpg_highway horsepower weight / transparency=0.5 markerattrs=(symbol=CircleFilled);
run;
1
PROC SGSCATTERDATA=sashelp.cars(where=(type in ('Sedan''Sports')));
Explanation : This block configures the Output Delivery System (ODS) for the second scatterplot matrix. It resets graphic options and sets a new image name ('matrix2') while maintaining the same dimensions and formats.
Explanation : This procedure generates a scatterplot matrix for the `sashelp.iris` dataset. The title is 'Scatterplot Matrix for Iris Data'. The matrix is constructed from the variables 'SepalLength', 'SepalWidth', 'PetalLength', 'PetalWidth', grouped by 'Species', with 0.5 transparency and filled circle markers.
Copied!
proc sgscatter data=sashelp.iris;
title "Scatterplot Matrix for Iris Data";
matrix SepalLength SepalWidth PetalLength PetalWidth / group=Species transparency=0.5 markerattrs=(symbol=CircleFilled);
run;
Explanation : This block configures the Output Delivery System (ODS) for the third scatterplot matrix. It resets graphic options and sets a new image name ('matrix3') while maintaining the same dimensions and formats.
Explanation : This procedure generates a scatterplot matrix for the `sashelp.iris` dataset, but uses the `compare` statement to create a cross scatterplot matrix. The variables 'SepalLength' and 'SepalWidth' are compared to 'PetalLength' and 'PetalWidth', grouped by 'species', with filled circle markers.
Copied!
proc sgscatter data=sashelp.iris;
title "Scatterplot Matrix for Iris Data";
compare x=(SepalLength SepalWidth)
y=(PetalLength PetalWidth)
/ group=species markerattrs=(symbol=CircleFilled);
run;
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.
Copyright Info : Created : 03/11/2017 (fr), Last update : 03/11/2017, Author(s) : Nicolas Dupont
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.