I run SAS EG version 9.04.01M4P110916 on a LIN X64 operating system in an Azure cloud.
I create ODS PDF reports that present a series of proc sgplot graphs in them. On this graph, red the arrow points to extra space between the lowest value on the vertical axis ($0) and the line for the x-axis.
I suspect that space is there because I am combining multiple plot types -- vbarparm, series and scatter -- but I do not understand why it happens.
Two questions: why does that space appear, and can I get rid of it?
This is the dataset that produces the graph:
This is the resolved code that creates the graph. Data indicating the RecessionYear is not in the dataset because no years of economic recession happened during the time period shown on the graph.
%macro samplegraph;
*** The graph components need to be rendered in the order in which this code is written for everything to work correctly for US clients. ***;
proc sgplot data=allgiftsalldonorsbyyr noborder;
*** force space at top of graph so recession bars are always tallest ***;
vbarparm category=mmyyrange
response = InflCumMedTen /
barwidth=0.1
nooutline
transparency=1
baseline= 0
;
*** There are no years of economic recession in the dataset for the time period, so in this example &recessioncheck20 = 0 ***;
%if &recessioncheck20 > 0 %then %do;
vbarparm category=mmyyrange
response=RecessionYear /
y2axis
barwidth=0.95
nooutline
fill fillattrs=(color=&BB_TertBlue25T transparency=0.3)
legendlabel="Recession Year"
name="rec"
baseline=0
;
%end;
*** These bars for InflAdjCumMed are here only to show the dollar amounts above the purple dashes in the scatterplot below. Labeling the scatterplot markers does not work as concisely as how I want the labels to look. ***;
vbarparm category=mmyyrange
response=InflAdjCumMed /
barwidth=1
nooutline
fill fillattrs=(color=white transparency=1.0)
datalabel datalabelattrs=(color=CX936DAF family="CorporateSans_Thin" size=9pt weight=bold)
baseline=0
;
vbarparm category=mmyyrange
response=med_cumul_gifts /
barwidth=0.75
nooutline
fill fillattrs=(color=CX00B795)
seglabel seglabelfitpolicy=thin seglabelattrs=(color=white family="CorporateSans_Thin" size=9pt weight=bold)
legendlabel="Median Cumulative Giving"
name="cumul"
baseline=0
;
series x=mmyyrange y=mediangifts /
lineattrs=(color=CXFBB034 thickness=2)
name="med"
legendlabel="Median Gift Transaction"
;
symbolchar name=dash char='2014'x / textattrs=(weight=bold);
scatter x=mmyyrange y=InflAdjCumMed /
markerattrs=(color=CX936DAF symbol=dash size=25pt)
name="infl"
;
xaxis display=(nolabel) valueattrs=(size=9pt family="Corporate Sans" color=CX4D525a);
yaxis display=(nolabel) valueattrs=(size=9pt family="Corporate Sans" color=CX4D525a)
grid gridattrs=(color=CXdbdcde);
y2axis min=0 display=none;
format InflAdjCumMed med_cumul_gifts bigmoney.;
%if &recessioncheck20 > 0 %then %do;
keylegend "cumul" "infl" "med" "rec" / title="" noborder across=2
autooutline position=bottom valueattrs=(size=8pt family="Corporate Sans" color=CX4D525a);
%end;
%else %if &recessioncheck20 = 0 %then %do;
keylegend "cumul" "infl" "med" / title="" noborder across=2
autooutline position=bottom valueattrs=(size=8pt family="Corporate Sans" color=CX4D525a);
%end;
where ngvrange le 20;
run;
%mend samplegraph;
%samplegraph
The bigmoney. format is defined as:
proc format;
picture bigmoney (round)
1E00-<1000='000' (prefix='$')
1E03-<1000000='000000.0K' (prefix='$' mult=.01)
1E06-<1000000000='0000000.0M' (prefix='$' mult=.00001)
1E09-<1000000000000='0000000000.0B' (prefix='$' mult=.00000001)
1E012-<1000000000000000='0000000000000.0T' (prefix='$' mult=.00000000001)
;
run;
Please let me know if I need to provide more information. Thanks for your help and insight.
Debra
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.