I am using this code within ods rtf. I want my chart/image on the left with no header and my table on the right of the chart. Tried a few things but I either get a massive header or my column is too small for the image.
data summary;
length Average $10 Maximum $10;
Average="&avg";
Maximum="&max.";
run;
data x;
set summary;
x=' ';output;
run;
title;
proc report data=x nowd style={outputwidth=100% cellspacing=0 cellpadding=1};
column x Average Maximum;
define x/display "" style={cellwidth=3in cellheight=3in};
define Average/display "Average amount" style={cellwidth=1in cellheight=0.5in} style(header)={cellwidth=1in cellheight=0.5in foreground=white background=CX002B49};
define Maximum/display "Maximum amount" style={cellwidth=1in cellheight=0.5in} style(header)={cellwidth=1in cellheight=0.5in foreground=white background=CX002B49};
compute x;
call define('x','style','style={ preimage="&report_loc.\max.png" bordertopcolor=white borderbottomcolor=white borderrightcolor=white borderleftcolor=white}');
endcomp;
run;
So you want this ?
%let path= c:\temp ;
options nodate nonumber;
ods listing gpath="&path." style=htmlblue image_dpi=300;
ods graphics /width=3in height=2in reset=index noborder imagename='FAS' outputfmt=png ;
proc sgplot data=sashelp.stocks noautolegend ;
where stock='IBM';
series x=date y=close;
run;
data x;
input mean1 &$20. max1 &$20.;
x='09'x;
cards;
. .
. .
. .
Average Daily Maximum Daily
3 7
. .
. .
. .
. .
. .
;
run;
title;
ods rtf file="&path.\want.rtf" style=minimal dpi=300 ;
proc report data=x nowd spanrows style={outputwidth=70% }
style(header)={bordertopcolor=white borderbottomcolor=white borderrightcolor=white borderleftcolor=white};
column x mean1 max1;
define x/order '09'x
style(column)={ preimage="&path\FAS1.png" bordertopcolor=white borderbottomcolor=white borderrightcolor=white borderleftcolor=white}
style(header)={ cellwidth=20% bordertopcolor=white borderbottomcolor=white borderrightcolor=white borderleftcolor=white};
define mean1/display '09'x style(header)={ cellwidth=5%};
define max1/display '09'x style(header)={ cellwidth=5%};
compute max1;
if missing(max1) then
call define(_row_,'style','style={bordertopcolor=white borderbottomcolor=white borderrightcolor=white borderleftcolor=white}');
else do;
call define(_row_,'style','style={bordertopcolor=black bordertopwidth=2}');
if max1=:'Max' then call define(_row_,'style','style={background=navy foreground=white fontweight=bold}');
end;
endcomp;
run;
ods rtf close;
If you want to mix graph and report, I would like to print this report as a graph and print it in RTF file.
Here is an example:
%let path= c:\temp ; options nodate nonumber; ods listing gpath="&path." style=htmlblue image_dpi=300; ods graphics /width=3in height=3in reset=index noborder imagename='FAS' outputfmt=png ; proc sgplot data=sashelp.class noautolegend ; reg x=height y=weight/cli clm; run; options papersize=(3in 3in); ods printer file="&path.\report.png" printer=png; proc report data=sashelp.class nowd style={outputwidth=100% }; run; ods printer close; options papersize='A4'; ods rtf file="&path.\want.rtf" style=minimal dpi=300 ; data x; x=' ';y=' ';output; run; title; proc report data=x nowd noheader style={outputwidth=100% }; column x y; define x/display; define y/display; compute y; call define('x','style','style={ preimage="&path\FAS1.png" bordertopcolor=white borderbottomcolor=white borderrightcolor=white borderleftcolor=white}'); call define('y','style','style={ preimage="&path\report.png" bordertopcolor=white borderbottomcolor=white borderrightcolor=white borderleftcolor=white}'); endcomp; run; ods rtf close;
I think it is very hard for RTF. Maybe @Cynthia_sas know some solution.
"my ods printer isn't saving the image"
That is really weird. Can you post the LOG info after running the following code ?
And Can you see a graph named report.png under path "&path." ?
options papersize=(3in 3in);
ods printer file="&path.\report.png" printer=png style=htmlblue dpi=300;
proc report data=sashelp.class nowd style={outputwidth=100% };
run;
ods printer close;
Ha. I found a workaround way here:
%let path= c:\temp ;
options nodate nonumber;
ods listing gpath="&path." style=htmlblue image_dpi=300;
ods graphics /width=3in height=3in reset=index noborder imagename='FAS' outputfmt=png ;
proc sgplot data=sashelp.class noautolegend ;
reg x=height y=weight/cli clm;
run;
ods rtf file="&path.\want.rtf" style=minimal dpi=300 ;
data x;
set sashelp.class;
x='09'x;
run;
title;
proc report data=x nowd spanrows style={outputwidth=90% };
column x name sex age weight height;
define x/group ''
style(column)={ preimage="&path\FAS1.png" bordertopcolor=white borderbottomcolor=white borderrightcolor=white borderleftcolor=white}
style(header)={ cellwidth=50% bordertopcolor=white borderbottomcolor=white borderrightcolor=white borderleftcolor=white};
define name/display;
run;
ods rtf close;
That's great but I still having problems.
I have been fiddling with it for awhile. If I use group or noprint on the x column, the image goes above the table. If I don't, I get the image repeating.
I realise the what the issue is but haven't found solution.
If you do noheader, it puts image above table.
I need to color in the header just for the table columns. Also, if I didn't use "noheader" the table is too big, the last row fills down to the height of the image.
I might have to do image by image but some reason I couldn't save table as png. Kept receiving error that the image didn't exist in my proc report because it wasn't saving.
So you want this ?
%let path= c:\temp ;
options nodate nonumber;
ods listing gpath="&path." style=htmlblue image_dpi=300;
ods graphics /width=3in height=2in reset=index noborder imagename='FAS' outputfmt=png ;
proc sgplot data=sashelp.stocks noautolegend ;
where stock='IBM';
series x=date y=close;
run;
data x;
input mean1 &$20. max1 &$20.;
x='09'x;
cards;
. .
. .
. .
Average Daily Maximum Daily
3 7
. .
. .
. .
. .
. .
;
run;
title;
ods rtf file="&path.\want.rtf" style=minimal dpi=300 ;
proc report data=x nowd spanrows style={outputwidth=70% }
style(header)={bordertopcolor=white borderbottomcolor=white borderrightcolor=white borderleftcolor=white};
column x mean1 max1;
define x/order '09'x
style(column)={ preimage="&path\FAS1.png" bordertopcolor=white borderbottomcolor=white borderrightcolor=white borderleftcolor=white}
style(header)={ cellwidth=20% bordertopcolor=white borderbottomcolor=white borderrightcolor=white borderleftcolor=white};
define mean1/display '09'x style(header)={ cellwidth=5%};
define max1/display '09'x style(header)={ cellwidth=5%};
compute max1;
if missing(max1) then
call define(_row_,'style','style={bordertopcolor=white borderbottomcolor=white borderrightcolor=white borderleftcolor=white}');
else do;
call define(_row_,'style','style={bordertopcolor=black bordertopwidth=2}');
if max1=:'Max' then call define(_row_,'style','style={background=navy foreground=white fontweight=bold}');
end;
endcomp;
run;
ods rtf close;
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.