BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Cingchih
Quartz | Level 8

How to let markers for mean and median to locate at the correct points?

Any help would be greatly appreciated!

 

my code:

proc means data=sashelp.cars min max mean median;
class type origin;
var mpg_city;
ods output summary=a;
run;

ods graphics/ imagefmt=png width=800px height=600px;
proc sgplot data=a;
highlow x=origin high=MPG_city_max  low=MPG_City_min  /  group=type type=bar  groupdisplay=cluster highlabel=MPG_city_max  
                                            lowlabel=MPG_City_min  labelattrs=(size=10) barwidth=1 clusterwidth=0.8   lineattrs=graphoutlines ;
scatter x=origin y=MPG_city_mean / group=type markerattrs=(symbol=circlefilled size=10 color=red) ;
scatter x=origin y=MPG_city_median /group=type markerattrs=(symbol=Diamondfilled size=10 color=red) ;
xaxis display=(nolabel noticks) valueattrs=(size=12);
yaxis label="Mpg City" labelattrs=(size=12) valueattrs=(size=12);
run;
ods graphics off;

my result:

SGPlot8.png

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Add  groupdisplay=cluster  in it.

 

proc means data=sashelp.cars min max mean median;
class type origin;
var mpg_city;
ods output summary=a;
run;

ods graphics/ imagefmt=png width=800px height=600px;
proc sgplot data=a;
highlow x=origin high=MPG_city_max  low=MPG_City_min  /  group=type type=bar  groupdisplay=cluster highlabel=MPG_city_max  
                                            lowlabel=MPG_City_min  labelattrs=(size=10) barwidth=1 clusterwidth=0.8   lineattrs=graphoutlines ;
scatter x=origin y=MPG_city_mean / group=type markerattrs=(symbol=circlefilled size=10 color=red) 
 groupdisplay=cluster ;
scatter x=origin y=MPG_city_median /group=type markerattrs=(symbol=Diamondfilled size=10 color=blue) 
 groupdisplay=cluster ;
xaxis display=(nolabel noticks) valueattrs=(size=12);
yaxis label="Mpg City" labelattrs=(size=12) valueattrs=(size=12);
run;

View solution in original post

2 REPLIES 2
Ksharp
Super User

Add  groupdisplay=cluster  in it.

 

proc means data=sashelp.cars min max mean median;
class type origin;
var mpg_city;
ods output summary=a;
run;

ods graphics/ imagefmt=png width=800px height=600px;
proc sgplot data=a;
highlow x=origin high=MPG_city_max  low=MPG_City_min  /  group=type type=bar  groupdisplay=cluster highlabel=MPG_city_max  
                                            lowlabel=MPG_City_min  labelattrs=(size=10) barwidth=1 clusterwidth=0.8   lineattrs=graphoutlines ;
scatter x=origin y=MPG_city_mean / group=type markerattrs=(symbol=circlefilled size=10 color=red) 
 groupdisplay=cluster ;
scatter x=origin y=MPG_city_median /group=type markerattrs=(symbol=Diamondfilled size=10 color=blue) 
 groupdisplay=cluster ;
xaxis display=(nolabel noticks) valueattrs=(size=12);
yaxis label="Mpg City" labelattrs=(size=12) valueattrs=(size=12);
run;

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 2 replies
  • 545 views
  • 0 likes
  • 2 in conversation