BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Whitlea
Obsidian | Level 7

I am trying to export an ods layout that contains a graph (the proc sgplot) with a table below it (the proc report).  I would like to export the image as an EMF.  This code will print the desired output in my results viewer, but the export file only contains the graph, not the table.  Is there a way to export both, as a group, and as an EMF? 

Thanks!

%MACRO TEST (Y1,Y2,values,TITLE1);

ods _all_ close;
options nodate nonumber;
options papersize=(7.35in 5.40in);
title &title1;
ods printer printer=emfdual; file="test.emf" style=normalprinter;
ods layout gridded rows=2 advance=proc;
ods graphics / reset=all outputfmt=emf imagename="&y2" IMAGEFMT=EMFDual  height=2.72in width=5.35in border=on; 

proc sgplot data= Final noborder;
styleattrs datacontrastcolors=(cx3d5b58 cxabb091 cx002e6d cxffd100 cx7cbdeb cx00a5cf cx679436 cxd68d45);
series y=&y1 x=date2 / group=Type /*datalabel=&y1 DATALABELATTRS=(family='Roboto' SIZE=8pt weight=bold color=black)*/
MARKERS MARKERATTRS=(SYMBOL=CircleFilled  size=6) LINEATTRS = ( pattern=solid THICKNESS=2);
keylegend / noborder;
yaxis grid VALUES = (&values) display=(noline noticks) valueATTRS=(family='Roboto' size=8pt)
label=" " LABELATTRS=(family='Roboto' size=8pt);
XAXIS   TYPE = discrete  display=( noline noticks)label=" " 
LABELATTRS=(family='Roboto' size=8pt) valueATTRS=(family='Roboto' size=8pt) ;
title1  &title1;
run;

ods region;
ods layout gridded rows=2 advance=proc;
ods graphics / reset=all outputfmt=emf imagename="&y2" IMAGEFMT=EMFDual  height=3.72in width=5.35in border=on; 

proc report data=Final nowd;
columns  Type &y1, date2;
define Type / group style=[cellwidth=3cm just=c];
define date2 / across '' order=data style=[cellwidth=3cm just=c] ;
define &y1 / analysis '' style=[cellwidth=3cm just=c];
run;

ods layout end; 
ods layout end;
ods printer close;

%MEND TEST;


%TEST ( OOH_pct,OH_pct2,0 .20 .40 .60 .80 1,"Title");
1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

You could embedded a picture(report) in a graph.

https://blogs.sas.com/content/iml/2023/09/18/embed-graph-sgplot.html

 

Here is an example.

But you need to adjust it according to your requirement.

%let path= c:\temp ;

title;
ods graphics / reset=all;
options nodate nonumber;
options papersize=(1in 1in);
ods printer file="&path.\report.png" printer=png dpi=300; 
proc report data=sashelp.class(obs=6) nowd style={outputwidth=100% cellpadding=0 cellspacing=0 } ;
column name sex age;
run;
ods printer close;



%SGANNO;   
data anno;
%SGIMAGE(image="&path\report.png",   
         drawspace="wallpercent", x1=50, y1=98,
         anchor="topleft",
         border="true"         
         );
run;


ods listing gpath="&path." style=htmlblue image_dpi=300;
ods graphics / reset=all outputfmt=emf imagename="xxxxxxx" IMAGEFMT=EMFDual  height=800px width=1200px border=on;
title "Picture-In-a-Picture Image";
proc sgplot data=Sashelp.Heart sganno=anno;
  density Cholesterol / type=kernel group=Sex;
  yaxis grid;
  xaxis offsetmax=0.5;
run;

Ksharp_0-1743772326471.png

 

 

View solution in original post

2 REPLIES 2
Ksharp
Super User

You could embedded a picture(report) in a graph.

https://blogs.sas.com/content/iml/2023/09/18/embed-graph-sgplot.html

 

Here is an example.

But you need to adjust it according to your requirement.

%let path= c:\temp ;

title;
ods graphics / reset=all;
options nodate nonumber;
options papersize=(1in 1in);
ods printer file="&path.\report.png" printer=png dpi=300; 
proc report data=sashelp.class(obs=6) nowd style={outputwidth=100% cellpadding=0 cellspacing=0 } ;
column name sex age;
run;
ods printer close;



%SGANNO;   
data anno;
%SGIMAGE(image="&path\report.png",   
         drawspace="wallpercent", x1=50, y1=98,
         anchor="topleft",
         border="true"         
         );
run;


ods listing gpath="&path." style=htmlblue image_dpi=300;
ods graphics / reset=all outputfmt=emf imagename="xxxxxxx" IMAGEFMT=EMFDual  height=800px width=1200px border=on;
title "Picture-In-a-Picture Image";
proc sgplot data=Sashelp.Heart sganno=anno;
  density Cholesterol / type=kernel group=Sex;
  yaxis grid;
  xaxis offsetmax=0.5;
run;

Ksharp_0-1743772326471.png

 

 

Ksharp
Super User

I think you want this graph ?

data have;
 set sashelp.stocks;
if year(date)=2005;
keep stock date close;
run;


ods listing gpath="c:\temp" style=htmlblue image_dpi=300;
ods graphics / reset=all outputfmt=emf imagename="xxxxxxx" IMAGEFMT=EMFDual height=3.72in width=5.35in border=on;
proc sgplot data=have noautolegend;
  series x=date y=close/group=stock markers curvelabel curvelabelpos=max;
  xaxistable close/x=date class=stock colorgroup=stock;
run;

Ksharp_1-1743819587460.png

 

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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