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

I have the following code, with a vbarparm and a scatterplot.  If I remove the scatterplot, I get a nice graph with no extra lines; just the border around the graph.  If I uncomment the scatterplot, that works, except now I have an extra line - presumably some padding between pre-existing lines.  The bars now come from an origin line that is some distance above the box around the graph.

Is there any way to remove that line and/or padding?  I'm not entirely sure why it exists in the first place.  I do want the bars to originate from the bottom of the box line, not to originate from a nonexistent x axis line.

The general concept here is that I'm placing stat test results over the bars, and since I'm using groupdisplay=cluster I cannot use datalabel; so scatter with a position of 105 seemed most reasonable as a solution. I'd be happy to consider other solutions if there is a better way to do this.

Thanks!

data mydata;

length stub $15;

input

installation $

stub $

prop

;

top=105;

statresult=ifc(installation='Facility','†#*',' ');

datalines;

Facility Favorable 65

Facility Neutral 25

Facility Unfavorable 10

Region Favorable 75

Region Neutral 15

Region Unfavorable 10

Nation Favorable 55

Nation Neutral 25

Nation Unfavorable 20

;;;;

run;

proc template;

define statgraph mybarplot;

begingraph /;

layout overlay /

  xaxisopts=( display=( tickvalues )

  TickValueAttrs=( Size=8pt Family="Arial/Bold")

  type=discrete discreteopts=( TickValueFitPolicy=SplitRotate sortOrder=data ) )

  y2axisopts=(labelFitPolicy=Split)

  yaxisopts=( display=none labelFitPolicy=Split type=auto )

  x2axisopts=(display=none)

  y2axisopts=(labelFitPolicy=Split);

  BarChartParm X=installation Y=prop / primary=true Group=stub

  DataLabelAttrs=( Color=CX000000 Family="ARIAL" Size=8 Weight=bold ) Display=( Fill )

  barwidth=0.4 LegendLabel="Range" NAME="Facility" groupdisplay=stack

  grouporder=ascending dataskin=pressed

  ;

  scatterplot x=installation y=top / xaxis=X primary=false markercharacter= statresult;

   DiscreteLegend "Facility" / Location=Outside valign=bottom Title=" ";

endlayout;

endgraph;

end;

run;

proc sgrender data=mydata template=mybarplot;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

The bars lift up to accommodate the possibility of the scatter point plotting at the base of a bar and being clipped in half. If you do not think that will happen with you data, set OFFSETMIN=0 in your YAXISOPTS.

Hope that helps!

Dan

View solution in original post

2 REPLIES 2
DanH_sas
SAS Super FREQ

The bars lift up to accommodate the possibility of the scatter point plotting at the base of a bar and being clipped in half. If you do not think that will happen with you data, set OFFSETMIN=0 in your YAXISOPTS.

Hope that helps!

Dan

snoopy369
Barite | Level 11

Thanks DanH, figured it was something like that but couldn't find the place to set the option!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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