BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
twildone
Pyrite | Level 9

Hi....I am trying to format variables after the correlation matrix is derived so that the output table would have the formatted names. I get an error message. Any suggestions on how to format the variables...thanks

 

proc corr data=have plots=none spearman vardef=df fisher(alpha=0.05 biasadj=yes rho0=0 type=twosided);
	var Q15_1 Q15_2 Q15_3 $QuestionCharB.;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
To format names, you usually want variable labels, not formats. It's not clear what you're trying to accomplish here. Is it variable values or labels you want to change the display of?

View solution in original post

6 REPLIES 6
PaigeMiller
Diamond | Level 26

Your VAR statement cannot have formats in it.

 

I am trying to format variables after the correlation matrix is derived so that the output table would have the formatted names

 

I don't think this makes sense, as I suppose you could apply formats to the values of the Spearman correlations (or maybe you need to edit the template to do that, I have never tried either), but any format would not apply to the names of the variables.

--
Paige Miller
Reeza
Super User
To format names, you usually want variable labels, not formats. It's not clear what you're trying to accomplish here. Is it variable values or labels you want to change the display of?
twildone
Pyrite | Level 9
Spearman Correlation Statistics (Fisher's z Transformation)
Variable	With Variable	N	Sample Correlation	Fisher's z	Bias Adjustment	Correlation Estimate		H0:Rho=Rho0
							95% Confidence Limits	Rho0	p Value
Q15_1	Q15_2	5	0.97468	2.17827	0.12183	0.96781	0.585331	0.997955	0	0.0021
Q15_1	Q15_3	6	0.94118	1.74825	0.09412	0.92942	0.479666	0.992419	0	0.0025
Q15_1	Intake1	6	0.21004	0.21322	0.02100	0.18988	-0.734935	0.867725	0	0.7119
Q15_2	Q15_3	6	0.98518	2.44889	0.09852	0.98199	0.839296	0.998111	0	<.0001
Q15_2	Intake1	6	-0.10050	-0.10084	-0.01005	-0.09055	-0.840355	0.778201	0	0.8613
Q15_3	Intake1	8	0	0	0	0	-0.704673	0.704673	0	1.0000

Hi Reeza…. Each variable represents a question. What I am trying to do is to end up with the table above with the actual question for each variable. I did use the Questions as the variables and ran the proc corr but the variable names were truncated because the length of each question was too long for the variables. So I am wondering if it possible to do the formatting on the outputs table.

Reeza
Super User
Did you try applying variable labels?
twildone
Pyrite | Level 9

Hi Reeza…..No I haven't tried applying variable labels. I think I will have to just edit the table as needed. But thank you for your help...greatly appreciated.

ballardw
Super User

@twildone wrote:

Hi....I am trying to format variables after the correlation matrix is derived so that the output table would have the formatted names. I get an error message. Any suggestions on how to format the variables...thanks

 

proc corr data=have plots=none spearman vardef=df fisher(alpha=0.05 biasadj=yes rho0=0 type=twosided);
	var Q15_1 Q15_2 Q15_3 $QuestionCharB.;
run;

Since the VAR variables in Proc Corr are expected to be numeric then a character variable $QuestionCharB. really doesn't make any sense.

 

Are you actually attempting to change the values of the variables for the purpose of calculating correlation? You would need to do that in a data step prior to Proc Corr.

 

It might help to provide some example input data and what you are attempting to get as output from that data.

Provide the data in the form of a data step. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

 

Or alternately use one of the SAS supplied data sets in the SASHELP library to demonstrate.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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