Hello,
I am using PROC PSMATCH to generate a standardized mean difference plot. I want to output the plot to an RTF file, but everytime I do that, there is an additional title of "The PSMATCH Procedure", which I want to remove (see screenshot).
I tried using ODS NOPROCTITLE, but the "The PSMATCH Procedure" still outputs to my RTF file. Is there a way to remove "The PSMATCH Procedure"?
Below is some sample code:
ods noproctitle;
ods rtf file="C:\standardized_mean_diff_plot.rtf";
title font="calibri" height=12pt justify=left bold "Standardized Mean Difference Plot"
ods graphics on / reset noborder width=1000px height=1000px imagefmt=jpg;
ods select StdDiffPlot;
proc psmatch data=psdata region=cs;
class GROUP AGE SEX;
psmodel GROUP(Treated="Cases")= AGE SEX;
match method=optimal(k=1)
distance=lps
caliper=.
weight=none;
assess lps var=AGE SEX;
run;
ods graphics off;
ods rtf close;
You could post process the text file that ODS RTF creates and remove that string.
Change your Original ODS RTF statement to write to a temporary file.
filename rtf temp;
ods rtf file=rtf;
Then after closing the RTF destination copy the temp file to the target file and remove that string along the way.
data _null_;
infile rtf;
file "C:\standardized_mean_diff_plot.rtf";
input;
_infile_=tranwrd(_infile_,'{The PSMATCH Procedure\cell}','{\cell}');
put _infile_;
run;
I also want know . @Cynthia_sas might knows .
Could be a bug or special feature. I don't see any reason why proc psmatch should not be affected by "ods noproctitle". Just copied one of the examples from the docs, using Enterprise Guide 8.3 and html as default output destination, "ods noproctitle" seems to have no effect on the output, i still see the title "Proc PSMatch". Contacting tech-support is recommended.
@Ksharp wrote:
I think OP need PROC TEMPLATE to modify the template of PROC PSMATCH, especially for ENTRYTITLE statement in PROC TEMPLATE .
Yes, this could be a solution, but i still think it is a bug, that proc psmatch seems to ignore the ods option.
You could post process the text file that ODS RTF creates and remove that string.
Change your Original ODS RTF statement to write to a temporary file.
filename rtf temp;
ods rtf file=rtf;
Then after closing the RTF destination copy the temp file to the target file and remove that string along the way.
data _null_;
infile rtf;
file "C:\standardized_mean_diff_plot.rtf";
input;
_infile_=tranwrd(_infile_,'{The PSMATCH Procedure\cell}','{\cell}');
put _infile_;
run;
Hi Tom,
Apologies for the late reply - even though this is not the easiest solution, it works! I'll have to contact tech support to see if there's a better way, or if they can get the ods noproctitle glitch fixed. Thanks for your help!
Just be careful if the lines in the RTF file are ever longer than 32K bytes then this approach will have trouble.
There are ways to do this by treating the file as binary, but that takes a little more complex coding. The essential idea is to read in the file in blocks of characters. Each time you read a new block you concatenate it with the previous block, replace the string, split it back into two and write the previous block to the target. Make sure to write the final block. So you are essentially moving a two block window across the file to catch the cases where the string you are searching happened to be split across two blocks. The block size needs to be large enough to fully include the search term and short enough that you can concatenate two blocks into one character variable. So less than 16K bytes per block.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.