Published on :
Reporting SASHELP

Generation of Connected Scatterplots with SGPLOT

This code is also available in: Deutsch Español Français
Awaiting validation
The script configures the ODS graphical environment, sorts the SASHELP.IRIS dataset to prepare for sequential rendering, and generates two visualizations: a simple series linking petal length and width, and a version grouped by species.
Data Analysis

Type : SASHELP


The data comes from the standard SASHELP.IRIS table.

1 Code Block
ODS
Explanation :
Initial configuration of ODS graphical output: definition of the output path, resolution (DPI), dimensions, and image name.
Copied!
1ods listing gpath="/home/nicolasdupont0/resources_github/Graph/Correlation/img" image_dpi=200;
2ods graphics / reset = all attrpriority=color border = no width =500px height =300px imagename = "connected_scatterplot1" imagefmt = png outputfmt = png antialiasmax = 10000;
3 
2 Code Block
PROC SORT Data
Explanation :
Sorting Iris data by petal length and width. This step is crucial for the 'series' type plot (connected line) to follow a logical order.
Copied!
1 
2PROC SORT
3DATA=sashelp.iris out=iris;
4BY petallength petalwidth;
5RUN;
6 
3 Code Block
PROC SGPLOT
Explanation :
Generation of the first simple series plot connecting the points (x=length, y=width).
Copied!
1PROC SGPLOT DATA=iris;
2 title 'Fisher (1936) Iris Data';
3 series x=petallength y=petalwidth;
4RUN;
4 Code Block
PROC SGPLOT
Explanation :
ODS configuration for the second image and generation of the series plot grouped by species with a 'PRESSED' visual style.
Copied!
1ods graphics / reset = all attrpriority=color border = no width =500px height =300px imagename = "connected_scatterplot2" imagefmt = png outputfmt = png antialiasmax = 10000;
2PROC SGPLOT DATA=iris;
3 title 'Fisher (1936) Iris Data';
4 series x=petallength y=petalwidth / group=species DATASKIN=PRESSED;
5RUN;
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 : Author(s) : Nicolas Dupont | Created : 03/11/2017