BookmarkSubscribeRSS Feed
liamand
Calcite | Level 5

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


20170407_232423.jpg
10 REPLIES 10
Reeza
Super User

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. 

 

 

liamand
Calcite | Level 5

Sir, 

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

Jay54
Meteorite | Level 14

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.

liamand
Calcite | Level 5

ooooh

WarrenKuhfeld
Rhodochrosite | Level 12

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;

ballardw
Super User

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

liamand
Calcite | Level 5

this is not working for me (SAS 9.2)

Jay54
Meteorite | Level 14

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

liamand
Calcite | Level 5
ooh sorry, that reply was not to you.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 10 replies
  • 1772 views
  • 2 likes
  • 5 in conversation