Data visualization with SAS programming

Sgrender and Background Images

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 15
Accepted Solution

Sgrender and Background Images

Hello Everyone,

I am working on creating a powerpoint where my background is an image previously assigned with a template. The problem that I am encountering is when I add one of my graphics to the powerpoint. Currently the background is white. I have tried to change it to opaque but with no luck. I'm assuming it has something to do with the fact that the graph is being output to the powerpoint as an image. Is there anyway to assign a background image to the graph before it is output to the powerpoint? I have tried using iback= in my proc sgrender statement with no luck. Does anyone have any ideas?

proc template; 
define statgraph growth;
begingraph;
layout overlay /xaxisopts=(label=' ' display=(tickvalues))
				yaxisopts=(label=' ' display=(tickvalues))
				borderattrs=(color=white)
				walldisplay=none;
barchart x=grade_level y=ptarget /fillattrs=(color=CX4472C4) outlineattrs=(color=CX4472C4) barlabel=true barlabelattrs=(size=10pt)
		legendlabel='District Percent of Target' name='percent' barwidth=.38;
seriesplot x=grade_level y=one_year / lineattrs=(color=red pattern=4)
		legendlabel='Annual Target 100%' name='annual';
seriesplot x=grade_level y=low_mid / lineattrs=(color=tan pattern=2)
		legendlabel='National Low Mid Year' name='low';
seriesplot x=grade_level y=high_mid /lineattrs=(color=tan pattern=2)
		legendlabel='National High Mid Year' name='high';
discretelegend 'percent' 'annual' 'low' 'high'/ border=false location=outside valign=bottom displayclipped=true valueattrs=(size=10pt);
endlayout;
endgraph;
end;
run;

goptions reset=all iback="E:\Custom Reporting\2015 MOY Reporting\Appendix\Images for Appendix\growthbackground.jpg";
ods graphics /border=off imagefmt=png;
ods layout gridded rows=2 columns=2;
ods region row=1 column=1 height=4.5in width=7in;
title1 j=left bold height=22pt "Percent of Target Growth Achieved at &mathematics_weeks Weeks";
title2 " ";
proc sgrender data=slide5_13 template=growth;
where subject='Mathematics';
run;

 

 


Accepted Solutions
Solution
‎12-21-2015 04:22 PM
SAS Super FREQ
Posts: 890

Re: Sgrender and Background Images

Sorry, the link is now invalid, but just search for the DRAWTEXT statement on the SAS support site.

 

Thanks!
Dan

View solution in original post


All Replies
SAS Super FREQ
Posts: 890

Re: Sgrender and Background Images

Use OPAQUE=FALSE on the BEGINGRAPH statement to mke the graph background transparent. If you also want the walls transparent, use WALLDISPLAY=(outline) to keep the outline, but make the walls transparent. WALLDISPLAY=NONE makes them both go away.

 

Hope this helps!

Dan

Occasional Contributor
Posts: 15

Re: Sgrender and Background Images

Hi DanH_sas,

Thanks so much for your quick response. I tried adding this line to my code, however i receive the following error:

 

proc template; 
define statgraph growth;
begingraph / OPAQUE=FALSE;
layout overlay /xaxisopts=(label=' ' display=(tickvalues))
				yaxisopts=(label=' ' display=(tickvalues))
				borderattrs=(color=white)
				walldisplay=none;
barchart x=grade_level y=ptarget /fillattrs=(color=CX4472C4) outlineattrs=(color=CX4472C4) barlabel=true barlabelattrs=(size=10pt)
		legendlabel='District Percent of Target' name='percent' barwidth=.38;
seriesplot x=grade_level y=one_year / lineattrs=(color=red pattern=4)
		legendlabel='Annual Target 100%' name='annual';
seriesplot x=grade_level y=low_mid / lineattrs=(color=tan pattern=2)
		legendlabel='National Low Mid Year' name='low';
seriesplot x=grade_level y=high_mid /lineattrs=(color=tan pattern=2)
		legendlabel='National High Mid Year' name='high';
discretelegend 'percent' 'annual' 'low' 'high'/ border=false location=outside valign=bottom displayclipped=true valueattrs=(size=10pt);
endlayout;
endgraph;
end;
run;

 

ERROR 22-322: Syntax error, expecting one of the following: ;, ATTRPRIORITY, BACKGROUNDCOLOR, BORDER, BORDERATTRS,
COLLATION, DATACOLORS, DATACONTRASTCOLORS, DATALINEPATTERNS, DATASKIN, DATASYMBOLS, DESIGNHEIGHT,
DESIGNWIDTH, DRAWSPACE, INCLUDEMISSINGDISCRETE, PAD, SUBPIXEL.
ERROR 76-322: Syntax error, statement will be ignored.

 

Could it be the version I am using. I am currently working with SAS 9.4 TS Level 1M1. 

SAS Super FREQ
Posts: 890

Re: Sgrender and Background Images

Unfortunately, we added the OPAQUE option on BEGINGRAPH at SAS 9.4m3. However, you asked about adding an image to your graph background when you generate the graph. You can do that using the DRAWIMAGE statement (http://support.sas.com/documentation/cdl/en/grstatgraph/67882/HTML/default/viewer.htm#n1gyqh8pgqnccw... Be sure to set the size to be the size of your graph, and set LAYER=BACK. Let me know if this works for you.

 

Thanks!
Dan

Solution
‎12-21-2015 04:22 PM
SAS Super FREQ
Posts: 890

Re: Sgrender and Background Images

Sorry, the link is now invalid, but just search for the DRAWTEXT statement on the SAS support site.

 

Thanks!
Dan

Occasional Contributor
Posts: 15

Re: Sgrender and Background Images

Thanks Dan. This worked perfectly! Thanks so much for your quick response. 

Occasional Contributor
Posts: 15

Re: Sgrender and Background Images

Thanks again for all your help. I do have one more quesiton. The image worked, however I now have a white border around the image that I cannot seem to remove. 

proc template; 
define statgraph growth;
begingraph;
layout overlay /xaxisopts=(label=' ' display=(tickvalues))
				yaxisopts=(label=' ' display=(tickvalues))
				walldisplay=none;
barchart x=grade_level y=ptarget /fillattrs=(color=CX4472C4) outlineattrs=(color=CX4472C4) barlabel=true barlabelattrs=(size=10pt)
		legendlabel='District Percent of Target' name='percent' barwidth=.38;
seriesplot x=grade_level y=one_year / lineattrs=(color=red pattern=4)
		legendlabel='Annual Target 100%' name='annual';
seriesplot x=grade_level y=low_mid / lineattrs=(color=tan pattern=2)
		legendlabel='National Low Mid Year' name='low';
seriesplot x=grade_level y=high_mid /lineattrs=(color=tan pattern=2)
		legendlabel='National High Mid Year' name='high';
discretelegend 'percent' 'annual' 'low' 'high'/ border=false location=outside valign=bottom displayclipped=true valueattrs=(size=10pt) opaque=false;
drawimage "E:\Custom Reporting\2015 MOY Reporting\Appendix\Images for Appendix\graphbackground.jpg" / layer=back scale=fit border=false height=200 width=200 x=0 y=0;
endlayout;
endgraph;
end;
run;
SAS Super FREQ
Posts: 890

Re: Sgrender and Background Images

Without seeing the output, my guess is that the padding around the graph is causing this issue. On the BEGINGRAPH statement, try setting PAD=0 and see if the white goes away.

Occasional Contributor
Posts: 15

Re: Sgrender and Background Images

You have officially made my day! Thanks again. 

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 635 views
  • 0 likes
  • 2 in conversation