Very new to SAS! I currently have a plot with all my data points but I want to just have averages. Is there a way to code in that I want to do an average of a variable within the sgplot procedure. I thought I could just do y=AVE(Variable Name) but that didn't work. Then I thought I could create the variables almost with an average but I don't know how to do that.
Any ideas?? Sorry if this is something super easy I just couldn't find an answer when googling. Thank you!
proc sgplot data=WORK.IMPORT1;
title 'TITLE';
scatter x=Variable1 y=Varaible2 / group=Variable3;
run;
Averages of your data broken down by what? You really haven't given us a lot to work with here. How about some more details?
Sorry about that. Im not really sure how to describe things just yet. I have two categorical variables (from my code Variable 2 and Variable 3) So i want the averages of all Variable1 data, for groups 1-4 of Variable3, throughout 6 phases of Variable2. So my y axis would only have 6 points, and in the chart i would only have four points associated there being the averages of Variable1 for each group of Variable3.
I feel like Im not saying this very clearly but am not really sure how else to describe this. Im sorry!
How about using PROC SUMMARY to compute the 24 means you want, then PROC SGPLOT with the DOT command to do the plotting.
Ok this was my code and I am getting the error: "Attempting to overlay incompatible plot or chart types"
proc sgplot data=WORK.IMPORT1;
title 'TITLE';
scatter x=Variable1 y=Variable2 / group=Variable3;
DOT Variable3 / STAT=Mean RESPONSE=Variable2;
run;
Certain graph types allow you to summarize the data while graphing it, unfortunately scatter plots are not one of them.
You will need to first summarize your data using PROC MEANS and capture that in an output table. Then use that with PROC SGPLOT.
Here's an example of how to use PROC MEANS and get an output data set.
https://github.com/statgeek/SAS-Tutorials/blob/master/proc_means_basic.sas
@jheinsius wrote:
Very new to SAS! I currently have a plot with all my data points but I want to just have averages. Is there a way to code in that I want to do an average of a variable within the sgplot procedure. I thought I could just do y=AVE(Variable Name) but that didn't work. Then I thought I could create the variables almost with an average but I don't know how to do that.
Any ideas?? Sorry if this is something super easy I just couldn't find an answer when googling. Thank you!
proc sgplot data=WORK.IMPORT1;
title 'TITLE';
scatter x=Variable1 y=Varaible2 / group=Variable3;
run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.