- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
How about using PROC SUMMARY to compute the 24 means you want, then PROC SGPLOT with the DOT command to do the plotting.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;