BookmarkSubscribeRSS Feed
skim2
Calcite | Level 5

I ran the PSMATCH with a "stddiff" plot option. I would like to know a way to reduce the font size of covariates (Y-axis) generated in the plots after running the PSMATCH.

 

proc psmatch data=SampleData;
psmodel mpk_flag(Treated='0') = age diabetes ischemic_heart_disease intellectual_disabilities ;
match method=optimal stat=lps caliper=0.5;
assess lps var=(age diabetes ischemic_heart_disease intellectual_disabilities) / plots=StdDiff;
output out(obs=match)=MatchedData weight=attwgt;
run;

6 REPLIES 6
FreelanceReinh
Jade | Level 19

Hello @skim2 and welcome to the SAS Support Communities!

 

I would rather change the font size before running PROC PSMATCH. To this end, you can create a modified version of the ODS template PROC PSMATCH uses for the StdDiff plot. See Re: PROC PSMATCH: Is there a way to change the x-axis label ... for more details and caveats.

 

In short:

  1. Submit
    ods path show;
    and make sure that the "Current ODS PATH list" that is written to the log looks like this:
    1. WORK.TEMPLAT(UPDATE)
    2. SASUSER.TEMPLAT(READ)
    3. SASHELP.TMPLMST(READ)
    That is, you can only "update" the temporary WORK.TEMPLAT store, while the SAS-supplied template stores are "read"-only.
  2. Copy the PROC TEMPLATE code of Stat.PSMatch.Graphics.StdDiffPlot (path in the Templates window: Sashelp.Tmplstat\Stat\PSMatch\Graphics\StdDiffPlot) from the template browser into your program editor.
  3. In the bottom half of that code you see the "else" branch of an "if (_VERTICAL)" statement. The "else" branch starts with a "Layout Overlay" statement ending with
    viewmax=_YMAX));
  4. Insert the instruction for your desired font size change before the last closing parenthesis, for example:
    viewmax=_YMAX) tickvalueattrs=(size=7pt));
    (the default font size seems to be 9pt, but may depend on the ODS style).

 

Now run this modified PROC TEMPLATE step and your PROC PSMATCH code and check the result in the graph. Adjust the SIZE= specification (7pt) in the PROC TEMPLATE code as needed.

skim2
Calcite | Level 5

Your explanations are very helpful. It worked well. Thank you, @FreelanceReinh.

skim2
Calcite | Level 5

It looks like the maximum number of characters displayed for each covariate is fixed at 20. Is there a way to increase the maximum number (or length) of characters?

FreelanceReinh
Jade | Level 19

@skim2 wrote:

It looks like the maximum number of characters displayed for each covariate is fixed at 20. Is there a way to increase the maximum number (or length) of characters?


I know that several SAS/STAT procedures, for example PROC LOGISTIC, PROC GLM and PROC LIFEREG, have a default length of 20 characters for names of effects or covariates, which can be overridden by the NAMELEN= option of the respective PROC statement. However, according to the documentation, PROC PSMATCH is not among those procedures and in my tabular and graphical outputs (using SAS/STAT 14.3) your longer variable names ischemic_heart_disease and intellectual_disabilities are not truncated, even if I increase the font size for the StdDiff plot to 24pt. Where do you see covariate names truncated to 20 characters?

skim2
Calcite | Level 5
Rather than displaying the variable names, I switched it as their labels. For example, I used it as intellectual disabilities'n. but, it was truncated up to 20 characters.
FreelanceReinh
Jade | Level 19

@skim2 wrote:
Rather than displaying the variable names, I switched it as their labels. For example, I used it as intellectual disabilities'n. but, it was truncated up to 20 characters.

Can you please show your code? I don't see an option in PROC PSMATCH that would replace variable names with labels. Maybe it is not yet available in my relatively old SAS/STAT version. Or did you make that change in PROC TEMPLATE?

 

"intellectual disabilities'n" resembles a name literal. If you are using the SAS system option VALIDVARNAME=ANY, the variable name could be intellectual disabilities (without the underscore between the words) and the variable would be referred to as 'intellectual disabilities'n in the program. The name would also appear at the corresponding y-axis tick mark, as shown below (for completeness, I also renamed ischemic_heart_disease to 'ischemic heart disease'n).

StdDiff.png

 

So, using those non-standard variable names looks like a solution for your truncation issue because, as you can see, the names are not truncated to 20 characters. In fact, they can be up to 32 characters long, so even severe intellectual disabilities would be a valid variable name (and not be truncated) if you used

options validvarname=any;

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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