Hello all,
I created the plot below using the following code:
proc sgplot data=tmp;
where event in ('b', 'w');
vbar event / response=score stat=mean limitstat=CLM barwidth=0.3; XAXIS DISPLAY=(nolabel); RUN;
when I try to add the following statement to include individual values:
scatter x=event y=score /jitter markerattrs=(symbol=trianglefilled color=black size=8);
I receive the error:
ERROR: Attempting to overlay incompatible plot or chart types.
when I use the other way below it doesn't show me all the 20 obs that I have :
proc summary data=plot1 nway;
class event;
var score;
output out=work.summary (drop= _: )
mean= lclm= uclm= / autoname;run;
data work.newplot;
set plot1 work.summary ; run;
proc sgplot data=work.newplot;
where event in ('b', 'w' );
vbarparm category= event response=score/ barwidth=0.3
limitlower=score_lclm limitupper= score_uclm ;
scatter x=event y=score/markerattrs=(color=gray size=6 symbol=trianglefilled) ;
run;
it shows:
there are 11 points in each plot, it should be 20 in each not 11, I meant didn't show me all the obs.
Thanks
Scatter plot and vertical bar chart cannot be on the same plot, they must be on different plots. It's not really clear to me what you mean by "include individual point in bar chart".
Thanks, I edited my question, including extra one to show individual point
Data.
What is the question now? We have no data so can't tell what you might mean by "there are around 14 points not 20". Are there supposed to be just 14? If there are more then which 14 are desired.
Since I can count what appears to be 22 markers neither 14 not 20 make sense.
I meant there should be 20 points for each plot, but here shows 11 points for each plot
yes I had typo error 11 not 14, sorry.
Data.
Data
Data
How do you expect us to have any idea of what you want or describe what happens without actual data. in the form of a working data set.
@bhr-q wrote:
I meant there should be 20 points for each plot, but here shows 11 points for each plot
yes I had typo error 11 not 14, sorry.
If you expect XXX number of points and only see YYY and YYY<XXX it almost always means that either 1) you have duplicate values and they are overlaying or 2) you don't actually have XXX points.
If it is one of the above situations it can be answered very quickly by looking at the data.
Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the </> icon or attached as text to show exactly what you have and that we can test code against.
I didn't expect any one if my question is not clear.
@bhr-q wrote:
I didn't expect any one if my question is not clear.
Your question is extremely "not clear".
You think you should have 20 points and only see 11.
But you won't share the data so we can tell you exactly why you get 11.
Show us proc freq output for
Proc freq data=tmp; where event in ('b', 'w'); tables event * score / list missing; run;
@bhr-q wrote:
Thanks, I edited my question, including extra one to show individual point
I'm lost.
There is a section in the online help for Sgplot/ Sgpanel that has details on "Plot Type Compatibility". Search for it. Memorize it.
The page shows which plots may be used with others.
If you every wondered why there are HBAR/VBAR ad HBARPARM/VBARPARM this page might help. If you must overlay a SCATTER plot then you need to overlay with the HBARPARM or VBARPARM.
The Parm bit means you have to pre-summarize the data to set the bar heights.
Thanks so much. I was able to get the answer with your help. Now I have the right plot, 19 points for each plot would be correct. The important thing is that the initial plot showed me a much lower point than I expected; it doesn't matter is it 19 or is it 20, because I have several datasets, and one of them is 19 which shows here.
my aim was to figure out why show me a much lower point in my second approach
I had two approaches in my initial comments:
In my first way: I tried using the jitter option with a scatter statement alongside a vertical bar chart. but, I received an error stating 'overlay incompatible plot,' .
In my second approach, I missed to include the jitter option, which resolved the issue, so it would be enough to include “markerattrs=(color=gray size=6 symbol=trianglefilled)jitter” as a last line in my second approach
Thanks again, I also tried to remove the redcap_event_name in the below of my plot, I looked for legend but didn't do.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.