BookmarkSubscribeRSS Feed
ble9245
Fluorite | Level 6

Hello,

I am using PROC PSMATCH to make a standardized mean difference plot, and I want to change the label of the x-axis "Difference (Treated - Control)". Is there a way to remove this label, or change it to something else? Using ODS TRACE, I found that this plot is the "StdDiffPlot"

This is some SAS code I used to make a standardized mean difference plot on the CARS dataset using PROC PSMATCH.

data CARS;
set sashelp.CARS;
format CAR_TYPE $50.;
if TYPE = 'SUV' then CAR_TYPE = 'SUV';
if TYPE = 'Sedan' then CAR_TYPE = 'SEDAN';
if CAR_TYPE ne ' ';
run;

ods graphics on;
proc psmatch data=CARS region=cs;
	class CAR_TYPE;
	psmodel CAR_TYPE(Treated="SUV")=MPG_CITY;
	match method=optimal(k=1)
			distance=mah(lps)
			caliper=.
			weight=none;
	assess lps var=(MPG_CITY);
run;
ods graphics off;

 

Also see the attached screenshot where I highlighted the "Difference (Treated - Control)" label that I want to remove or re-label.

 

Std Diff Plot Example.JPG


Thank you in advance for any help or advice!

1 REPLY 1
FreelanceReinh
Jade | Level 19

Hello @ble9245,

 

You can edit the ODS template underlying the plot to achieve what you want. Normally I don't edit these templates, but a successful attempt in 2020 (which did not damage the original templates) and a recent second success last February encouraged me (EDIT: see the warning at the bottom of this post, though).

 

The first steps are described in items 1 - 3 of the 2020 post mentioned above, except that the template to be edited is StdDiffPlot in the Graphics subfolder of folder PSMatch (instead of Mixed).

 

As in the other post (Feb 2022) I simply copied the whole PROC TEMPLATE step from there into the Enhanced Editor. Then I edited the hardcoded label= suboption (label="Difference (Treated - Control)") of the xaxisopts= option of the Layout Overlay statement in the ELSE branch of the "if (_VERTICAL) ... else ..." construct:

label="Your Custom Axis Label"

(Note the similar code structure for the y-axis in the IF branch.)

 

After submitting the modified PROC TEMPLATE step (which saved the customized template to WORK.TEMPLAT, i.e., a temporary location) your PROC PSMATCH step created the plot with the modified x-axis label.

 

To remove the x-axis label, just edit the next suboption of the xaxisopts= option: In the default template it says display=all. Change this to

display=(line ticks tickvalues)

and the axis label will vanish (ignoring the value of the label= suboption).

 

To return to the original template I deleted the customized version in the WORK library:

 

proc template;
delete Stat.PSMatch.Graphics.StdDiffPlot;
run;

 

and verified that PROC PSMATCH now produced the original plot again.

 

Edit:

CAUTION: Thereafter, when I tried to open a second Templates window (View --> Templates) without a good reason as the first was still open, my SAS 9.4M5 session stopped responding, had to be terminated via "SAS System Close" and yet the Autosave file of the Enhanced Editor was deleted (luckily it didn't contain relevant code)! I remember the same happened after the previous ODS template modification in February. Even worse, the crash seemed to destabilize a second SAS session that I had opened while the first was non-responsive. So, be careful and save everything before playing around with the ODS templates.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 614 views
  • 0 likes
  • 2 in conversation