Table of Contents
SAS (Statistical Analysis System) is a powerful software used for data analysis and visualization. One of its commonly used features is the creation of scatter plots, which are graphical representations of data points plotted on a coordinate system. To create a scatter plot in SAS, one must first have a dataset with numerical variables that can be plotted on the x and y-axis. Then, using the SAS PROC SGPLOT procedure, the data can be plotted and customized with various options such as color, size, and labels. For example, to create a scatter plot showing the relationship between height and weight, the following code can be used:
proc sgplot data = mydata;
scatter x = height y = weight / markerattrs = (symbol = circlefilled color = blue size = 10)
xaxis label = ‘Height (inches)’ yaxis label = ‘Weight (lbs)’;
run;
This will produce a scatter plot with circles representing each data point, where the x-axis is labeled as “Height (inches)” and the y-axis is labeled as “Weight (lbs)”. By using different options and modifying the code, the appearance of the scatter plot can be customized to fit the needs of the user. In conclusion, creating scatter plots in SAS is a simple process that can be done with the use of the PROC SGPLOT procedure, allowing for effective visualization and analysis of numerical data.
Create Scatter Plots in SAS (With Examples)
You can use the following methods to create scatter plots in SAS:
Method 1: Create One Scatter Plot
proc sgplot data=my_data;
scatterx=var1 y=var2;
run;
Method 2: Create Scatter Plots by Group
proc sgplot data=my_data;
scatterx=var1 y=var2 / group=var3;
run;The following examples show how to use each method with the following dataset in SAS:
/*create dataset*/ data my_data; input team $ points rebounds; datalines; A 29 8 A 23 6 A 20 6 A 21 9 A 33 14 A 35 11 A 31 10 B 21 9 B 14 5 B 15 7 B 11 10 B 12 6 B 10 8 B 15 10 ; run;/*view dataset*/ proc printdata=my_data;

Example 1: Create One Scatter Plot
The following code shows how to create a scatterplot for the points and rebounds variables:
proc sgplot data=my_data;
scatterx=points y=rebounds;
run;
The x-axis displays the values for the points variable and the y-axis displays the values for the rebounds variable.
Note that we can also add a title to the plot and modify the appearance of the markers within the plot to make it more aesthetically pleasing:
title "Points vs. Rebounds";
proc sgplot data=my_data;
scatterx=points y=rebounds /
markerattrs=(symbol=CircleFilled size=12color=purple);
run;
Example 2: Create Scatter Plots by Group
title "Points vs. Rebounds by Team";
proc sgplot data=my_data;
scatterx=points y=rebounds /
markerattrs=(symbol=CircleFilled size=12)
group=team;
run;
This plot allows us to quickly visualize the relationship between points and rebounds for both team A and team B.
Additional Resources
The following tutorials explain how to create other charts in SAS:
Cite this article
stats writer (2024). How can I create scatter plots in SAS with examples?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-can-i-create-scatter-plots-in-sas-with-examples/
stats writer. "How can I create scatter plots in SAS with examples?." PSYCHOLOGICAL SCALES, 1 Jul. 2024, https://scales.arabpsychology.com/stats/how-can-i-create-scatter-plots-in-sas-with-examples/.
stats writer. "How can I create scatter plots in SAS with examples?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-can-i-create-scatter-plots-in-sas-with-examples/.
stats writer (2024) 'How can I create scatter plots in SAS with examples?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-can-i-create-scatter-plots-in-sas-with-examples/.
[1] stats writer, "How can I create scatter plots in SAS with examples?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, July, 2024.
stats writer. How can I create scatter plots in SAS with examples?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.
