BookmarkSubscribeRSS Feed
TimurShangareev
Calcite | Level 5

Hello. Suppose I use proc mixed to show Studentized Residuals and create .rtf file. 

TimurShangareev_0-1754579595450.png

 

If I want to change color and maybe some other graph options for each plots (Labels, Tick values).

I can try to use option UNPACK, and then somehow by using SGRENDER and proc template and layout lattice edit all possible options and show output datasets on Layout/Graph. But I don't know how to show Right-Bottom Corner (table with statistics [these are ODS OUTPUT fitstatistics and descriptive statistics obtained using proc means on ODS OUTPUT StudentByPredicted ]). How I can solve this?

Or maybe there is exists some way to edit style of StudentPanel? Something like:

ODS RTF BODY="..." style=styles.MyStyle;
ods graphics on;
proc mixed data=inds plots=StudentPanel;
class &class.;
model &model.; run; ods graphics off; ODS RTF CLOSE

Could you help me?

Also Tried ODS LAYOUT, but it seems that it doesn't work with RTF. 

5 REPLIES 5
Ksharp
Super User

You want this ?

Here is GTL solution. Another is using PROC REPORT check the next post.

data report;
input id label  & $20. a & $20. b;
cards;
1 Residual Statistics   Observations  184
1 Residual Statistics   Minimum   184
1 Residual Statistics   Mean      184
1 Residual Statistics   Maximum   184
1 Residual Statistics   Std Dev   184
2 Fit Statistics   Objective   184
2 Fit Statistics   AIC   184
2 Fit Statistics   AICC   184
2 Fit Statistics   BIC   184
;

%let path= c:\temp;  *the path stored the picture of report and desired RTF file;


ods _all_ close;
options printerpath=png nonumber nodate papersize=(4.5cm 7cm)  ; 
title;
ods printer file="&path.\report.png" style=journal dpi=300;
proc report data=report nowd noheader style(report)={frame=box};
columns id label a b;
define id/order noprint;
define label/order noprint;
compute before label;
if label ne lag(label) then n+1;
if n=1 then len=0;
 else len=10;
x=' ';
line x $varying10. len;
line label $40.;
endcomp;
run;
ods printer close;




%sganno
data sganno;
 %SGIMAGE(
     IMAGE="&path.\report.png",
     ANCHOR="CENTER" ,
     BORDER="FALSE",
	 IMAGESCALE="FIT" ,
	 HEIGHT=100,
     HEIGHTUNIT="PERCENT",
     DRAWSPACE="LAYOUTPERCENT",
     X1=50,
     Y1=50,ID="BAR"
     )
run;
proc template;
define statgraph y2axis;
begingraph;
layout lattice /rows=2 columns=2; * columngutter=10 rowdatarange=union row2datarange=union;


layout overlay;
histogram height / scale=percent yaxis=y;
densityplot height / normal();
endlayout;

layout overlay;
scatterplot x=weight y=height;
endlayout;

layout overlay;
loessplot x=weight y=height;
endlayout;


layout overlay / walldisplay=none yaxisopts=( display=none ) xaxisopts=( display=none )  ;
scatterplot x=weight y=height/markerattrs=(color=white);
annotate / id="BAR";
endlayout;


endlayout;
endgraph;
end;
run;


ods _all_ close;
options papersize=A4 leftmargin=0in rightmargin=0in leftmargin=0in rightmargin=0in;
ods rtf file="&path.\want.rtf" dpi=300 style=htmlblue; 
proc sgrender data=sashelp.class template=y2axis sganno=sganno;
run;
ods rtf close;

Ksharp_0-1754621930705.png

 

Ksharp
Super User

And Here is PROC REPORT solution.

 

data report;
input id label  & $20. a & $20. b;
cards;
1 Residual Statistics   Observations  184
1 Residual Statistics   Minimum   184
1 Residual Statistics   Mean      184
1 Residual Statistics   Maximum   184
1 Residual Statistics   Std Dev   184
2 Fit Statistics   Objective   184
2 Fit Statistics   AIC   184
2 Fit Statistics   AICC   184
2 Fit Statistics   BIC   184
;

%let path= c:\temp\a ;  *the path stored the picture of report and desired RTF file;


ods _all_ close;
options printerpath=png nonumber nodate papersize=(4.5cm 7cm)  ; 
title;
ods printer file="&path.\report.png" style=journal dpi=300;
proc report data=report nowd noheader style(report)={frame=box};
columns id label a b;
define id/order noprint;
define label/order noprint;
compute before label;
if label ne lag(label) then n+1;
if n=1 then len=0;
 else len=10;
x=' ';
line x $varying10. len;
line label $40.;
endcomp;
run;
ods printer close;




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 graphics /width=3in height=3in reset=index  noborder  imagename='PPS' outputfmt=png;
proc sgplot data=sashelp.class;
scatter x=age y=weight;
run;
ods graphics /width=3in height=3in reset=index  noborder  imagename='SS' outputfmt=png ;
proc sgplot data=sashelp.class noautolegend ;
ellipse x=height y=weight/group=sex;
scatter x=height y=weight/group=sex;
run;



ods _all_ close;
options papersize=A4 leftmargin=0in rightmargin=0in leftmargin=0in rightmargin=0in;
ods rtf file="&path.\want.rtf" dpi=300 style=htmlblue; 
data x;
x=' ';y=' ';output;
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;
n+1;
if n=1 then do;
call define('x','style','style={ preimage="&path\FAS.png"  bordertopcolor=white borderbottomcolor=white borderrightcolor=white borderleftcolor=white}');
call define('y','style','style={ preimage="&path\PPS.png"  bordertopcolor=white borderbottomcolor=white borderrightcolor=white borderleftcolor=white}');
end;
if n=2 then do;
call define('x','style','style={ preimage="&path\SS.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}');
end;
endcomp;
run;
ods rtf close;

Ksharp_0-1754623044510.png

 

TimurShangareev
Calcite | Level 5

Thanks.

I see both methods are storing images (graphs) in filesystem. Is it possible to avoid it and save it in some work environment or draw them directly in proc report?

TimurShangareev
Calcite | Level 5

I mean that in my team we do not create .png files in project directly. Our figures programms (fig_Number_XXX_.sas) have to not produce addtitional files exept sas datasets or output .rtf files.

Ksharp
Super User

Sure. Of course.

Just change the following line:

%let path= c:\temp\a ;

into

%let path= %sysfunc(pathname(work)) ;  

BTW, you also need to change the path of RTF file, otherwise the RTF file would be stored at WORK library.

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