BookmarkSubscribeRSS Feed
mdwilson
Fluorite | Level 6

I'm working with biological data and have a large number of concentrations for the same biochemical from two tissue types. I want to examine the correlation between the two tissue types for the same biochemical, i.e, chemical 1 from liver with chemical 1 from blood; chemical 2 from liver with chemical 2 from blood, etc. I don't want any of the other correlations. Is there a simple way to do this? The number of biochemical can range from 60 to over 300. I don't want to have to run Proc Corr 250 times if I can avoid it. The number of patients ranges from 10 to 30. I don't have a lot of experience with DO loops or macros in SAS, but I have a little.

 

Thanks!

2 REPLIES 2
Reeza
Super User

Depends a bit on your exact data layout but sounds like you want some BY group processing. Equivalent example with SASHELP.HEART which is the Framingham Heart study. 

In this case, it's looking for correlation between diastolic and systolic pressure for each type of cholesterol status. 

 

proc sort data=sashelp.heart out=heart;
by chol_status;
run;

proc corr data=heart;
by chol_status;
var diastolic systolic;
run;

If your data is not in the correct structure, you can restructure it with PROC TRANSPOSE. 

ballardw
Super User

Place some of the variables on the VAR statement and others on a WITH statement.

 

From the documentation

proc corr;
   var x1 x2;
   with y1 y2 y3;
run;

 

Will calculate correlations of X1 with y1, y2 and y3 plus X2 with y1, y2 and y3

 

You may end up with some results you don't actually want but those should be easy to ignore. Or use a couple of Proc Corr calls if there are way too many to deal with.

 

Your data should be structured so that each variable represents chem1Blood and chem1Liver for that approach.

OR possibly a one record per chemical and measurements at blood and liver. That would use a BY variable of chemical. Something like the following where "blood" is the variable with the blood measurement and "liver" is the variable with the liver measurement.

proc corr;
by chemical; var blood; with liver; run;

 

I am not clear on the role  of "patient" here as I would not expect to have lots of repeated values for a single patient.

 

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