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

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;

 

paul8_0-1743497229290.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

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;

Ksharp_0-1743643000089.png

 

View solution in original post

8 REPLIES 8
Ksharp
Super User

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;

Ksharp_0-1743499915743.png

 

paul8
Fluorite | Level 6
Ideally I wanted the table as a table to copy data over from the rtf file easier. If not possible, I will settle for image. This is a great example however my ods printer isn't saving the image
Ksharp
Super User

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;
Ksharp
Super User

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;

Ksharp_0-1743574233067.png

 

paul8
Fluorite | Level 6

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.

 
ods listing gpath="&report_loc." style=htmlblue image_dpi=300;
ods graphics / width=3in height=3in reset=index noborder imagename='max_chart' outputfmt=png;
      %* Create a plot of all concurrent sessions on the platform by day.;
      title color=CX002B49 "Title" ;
      proc sgplot data = marts.chart ;
        yaxis min = 0 max = &max_concurrent_to_display. label = "Daily" grid gridattrs=(color=black pattern=35);
        xaxis interval = month minorinterval= month type = time display = (nolabel);
  
        series x = connection_date y = concurrent_connections / lineattrs = (color = CX002B49 thickness = 1px /*pattern=4*/);
      run;      
      title;
 
 data c_table;
    length Average_Daily $25 Maximum_Daily $25;
    
    /* First row with header-like values */
    Average_Daily = "Average Daily";
    Maximum_Daily = "Maximum Daily";
    output;
    
    /* Second row with macro values */
    Average_Daily = "&&avg_c.";
    Maximum_Daily = "&max_c.";
    output;
run;
 
   
     data x;
set c_table;
       x='09'x;
     run;
     title;
 
proc report data=x nowd  noheader spanrows ;
  column x Average_Daily Maximum_Daily;
  define x /group ''
style(column)={ preimage="&report_loc.\max_concurrent.png" bordertopcolor=white borderbottomcolor=white borderrightcolor=white borderleftcolor=white}
style(header)={ cellwidth=50% bordertopcolor=white borderbottomcolor=white borderrightcolor=white borderleftcolor=white};
  define Average_Daily/display "Average Daily" style={cellwidth=1in cellheight=0.5in};
  define Maximum_Daily/display "Maximum Daily" style={cellwidth=1in cellheight=0.5in};
   compute Average_Daily;
    if Average_Daily="Average Daily"  then do;
      call define(_col_, "style", "style={background=blue foreground=white cellwidth=1in cellheight=0.5in}");
    end;
  endcomp;
  compute Maximum_Daily;
    if Maximum_Daily="Maximum Daily"  then do;
      call define(_col_, "style", "style={background=blue foreground=white cellwidth=1in cellheight=0.5in}");
    end;
  endcomp;
 
  run;
Need this table on the right of chart
paul8_0-1743606173045.png

 

paul8
Fluorite | Level 6

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.

Ksharp
Super User

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;

Ksharp_0-1743643000089.png

 

paul8
Fluorite | Level 6
Perfect! Thank you. You have been very helpful!

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
  • 8 replies
  • 2200 views
  • 3 likes
  • 2 in conversation