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

I am using PROC PSMATCH to make a standardized mean difference plot, and I want to know if it is possible to change the label of the variable, as the plot just uses the variable's default name. 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;

PROC PSMATCH Std Mean Diff Plot.png

 

 

For example, is it possible to change "MPG_City" to "Mpg in the City" in this plot?

 

Thank you in advance for any help or advice!

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

Mmm there might be no way to use a label.

Maybe like this if your site supports name literals (please don't use them unless necessary*)?

proc psmatch data=CARS(rename=(MPG_CITY='MPG In City'n)) region=cs;
	class CAR_TYPE;
	psmodel CAR_TYPE(Treated="SUV")='MPG In City'n;
	match method=optimal(k=1)
			distance=mah(lps)
			caliper=.
			weight=none;
	assess lps var=('MPG In City'n);
run;

* IMPORTANT Throughout SAS, using the name literal syntax with variable names that exceed the 32-byte limit or have excessive embedded quotation marks might cause unexpected results. The intent of the VALIDVARNAME=ANY system option is to enable compatibility with other DBMS variable (column) naming conventions, such as allowing embedded blanks and national characters. See https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lepg/n1m3fal4mygiy0n1fvq8v5ax2jfn.htm

 

 

View solution in original post

3 REPLIES 3
ChrisNZ
Tourmaline | Level 20

Mmm there might be no way to use a label.

Maybe like this if your site supports name literals (please don't use them unless necessary*)?

proc psmatch data=CARS(rename=(MPG_CITY='MPG In City'n)) region=cs;
	class CAR_TYPE;
	psmodel CAR_TYPE(Treated="SUV")='MPG In City'n;
	match method=optimal(k=1)
			distance=mah(lps)
			caliper=.
			weight=none;
	assess lps var=('MPG In City'n);
run;

* IMPORTANT Throughout SAS, using the name literal syntax with variable names that exceed the 32-byte limit or have excessive embedded quotation marks might cause unexpected results. The intent of the VALIDVARNAME=ANY system option is to enable compatibility with other DBMS variable (column) naming conventions, such as allowing embedded blanks and national characters. See https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lepg/n1m3fal4mygiy0n1fvq8v5ax2jfn.htm

 

 

ble9245
Fluorite | Level 6

Hi Chris,

 

This worked! Thank you so much for your help. It's useful how SAS has these name literals to allow special characters and flexibility in variable names. However, it is a bit of a pain to have to change the name of each variable to the name literal each time the variable is referenced.

 

I found this sample code that stores the name literals into macro variables, so that may be helpful if you need to make multiple name literals for multiple variables.

https://support.sas.com/kb/48/278.html

 

Thanks again for your help!

Banke
Pyrite | Level 9

I found this post helpful. I however noticed that labels with space in them e.g. 'Government insurance'n did not work because of the space in between. If I put a hyphen  '_'  between, it worked bu that does not fit the purpose

SAS Innovate 2025: Register Now

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 1157 views
  • 3 likes
  • 3 in conversation