Data visualization with SAS programming

Graph - Scatter Dot Plot with Symbol for Mean Value

Reply
Occasional Contributor
Posts: 5

Graph - Scatter Dot Plot with Symbol for Mean Value

[ Edited ]

How can I create a  graph as shown in attachment? and how can I reshape the frame of the graph?


20170407_232423.jpg
Grand Advisor
Posts: 17,461

Re: Graph

PROC SGPLOT for starters but it depends a bit on your data format.

I would use a Scatter statement for the points and a second Scatter statement for the mean. 

 

If you look through the posts on here, I think there was a request for exactly this type of graph in the last week, possibly two weeks. 

 

 

SAS Super FREQ
Posts: 1,081
Occasional Contributor
Posts: 5

Re: Graph

Sir, 

I am working on SAS 9.2. This solution is not working. Can you give me a better solution.

SAS Super FREQ
Posts: 1,081

Re: Graph

You will not be able to layer a VBOX with SCATTER in SAS 9.2.  You need atleast SAS 9.4 for this.

You will need to use the solution shown in the link "http://blogs.sas.com/content/graphicallyspeaking/2017/03/27/scatter-with-layer/", to compute the mean value using the MEANS procedure and then use a plot statement to layer that on the scatter plot (JITTER is also NOT available with SAS 9.2). 

 

However, you cannot use a HighLow plot as that too is not available with SAS 9.2.  You will need to use another SCATTER with a different symbol to display the mean value.

 

SAS 9.2 is over 8 years old.  It may be time to consider an upgrade.

Occasional Contributor
Posts: 5

Re: Graph

ooooh

SAS Employee
Posts: 91

Re: Graph

Here is one way you can do it without any data prep.  Of course the "color=white" specification is not going to work for all styles.  If you actually want the mean line labeled, you will need additional data prep.  Thanks to Prashant for part of this solution.

 

proc sgplot data=sashelp.class noautolegend;
   symbolChar name=longDash char='2014'x / textAttrs=GraphUnicodeText;
   vbox weight / category=sex nofill
            nomedian meanattrs=(symbol=longdash size=50px)
            whiskerattrs=(thickness=0) lineattrs=(color=white);
   scatter y=weight x=sex;
run;

Grand Advisor
Posts: 10,251

Re: Graph

possibly lineattrs=(thickness=0) to not display a line, background color independent.

Occasional Contributor
Posts: 5

Re: Graph

this is not working for me (SAS 9.2)

SAS Super FREQ
Posts: 1,081

Re: Graph

Please post your full program with data and log messages.  Just saying "It is not working" is not very meaningful.  

Occasional Contributor
Posts: 5

Re: Graph

ooh sorry, that reply was not to you.
Ask a Question
Discussion stats
  • 10 replies
  • 196 views
  • 2 likes
  • 5 in conversation