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

HI ,

 

can anyone please give some example code for the vertical bar graph with circles plotting on it.

 

Thanks,

Mahesh

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
data testdata;
  length city $9;
  city = "London"; dollar = 50; scatter = 45; output;
  city = "Dubai"; dollar = 40; scatter = 35; output;
  city = "New York"; dollar = 20; scatter = 25; output;
  city = "Las Vegas"; dollar = 60; scatter = 30; output;
run;

proc sgplot data=testdata noautolegend;
vbar city/response=dollar;
vline city/response=scatter LINEATTRS=(thickness=0) MARKERATTRS=(size=20 symbol=circlefilled color=orange) markers;
run;

Ksharp_0-1625660720277.png

 

View solution in original post

9 REPLIES 9
Reeza
Super User
What would that even look like? What would be on the axis? Is it dual axis?
pmksasbi
Fluorite | Level 6

SampleSample

x-axis with description of city , y axis with dollar, right side with no of assigned clients

 

djrisks
Barite | Level 11

Hello,

 

Here is some example code that you can use:

 

data testdata;
  length city $9;
  city = "London"; dollar = 50; scatter = 45; output;
  city = "Dubai"; dollar = 40; scatter = 35; output;
  city = "New York"; dollar = 20; scatter = 25; output;
  city = "Las Vegas"; dollar = 60; scatter = 30; output;
run;

proc template;
  define statgraph barwithcircle;
    begingraph;
	  layout overlay;
	    barchart x = city y = dollar;
		scatterplot x = city y = scatter / markerattrs = (size = 20 color = orange symbol = circlefilled);
	  endlayout;
	endgraph;
  end;
run;

proc sgrender data = testdata template = barwithcircle;
run;
  

The code produces the graph below.

 

Bar Chart with Circles.png

Reeza
Super User
proc sgplot data=testdata;
vbarparm category = city response=dollar;  *bar graph;
scatter x= city y=clients / y2axis; *scatter plot;
run;

See the section in the docs titled Basic-Compatible Bar Chart Examples for various other examples here

https://documentation.sas.com/doc/en/vdmmlcdc/1.0/grstatproc/n121lznfa1jnlvn1q95t0r5sd2gq.htm#p11meh...

 


@pmksasbi wrote:

SampleSample

x-axis with description of city , y axis with dollar, right side with no of assigned clients

 


 

pmksasbi
Fluorite | Level 6

thank you all

djrisks
Barite | Level 11

You're welcome. I also believe that my answer should have been marked as the solution since I created the data and answered it first.

pmksasbi
Fluorite | Level 6

i am sorry, since i marked it . i am unable to make any changes

Reeza
Super User

@pmksasbi wrote:

i am sorry, since i marked it . i am unable to make any changes


Actually it can ben updated, click the three dots beside the post currently marked as solved.

 

@djrisks As to which solution to mark as correct - the OP should mark the solution that best fits their needs, ie if the SGPLOT solution is simpler that is a valid selection over an SGRENDER solution.

 

 

Ksharp
Super User
data testdata;
  length city $9;
  city = "London"; dollar = 50; scatter = 45; output;
  city = "Dubai"; dollar = 40; scatter = 35; output;
  city = "New York"; dollar = 20; scatter = 25; output;
  city = "Las Vegas"; dollar = 60; scatter = 30; output;
run;

proc sgplot data=testdata noautolegend;
vbar city/response=dollar;
vline city/response=scatter LINEATTRS=(thickness=0) MARKERATTRS=(size=20 symbol=circlefilled color=orange) markers;
run;

Ksharp_0-1625660720277.png

 

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
  • 9 replies
  • 1314 views
  • 11 likes
  • 4 in conversation