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: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 9 replies
  • 1487 views
  • 11 likes
  • 4 in conversation