Hello @kakahingwong and welcome to the SAS Support Communities!
So you want to compute partial correlations based on an existing correlation dataset. This is possible. However, it seems that PROC CORR doesn't like to process its own output datasets: You must have got the log message
WARNING: The input TYPE=CORR data set is treated as an ordinary SAS data set in proc CORR.
in addition to (as you noticed) nonsense results.
Luckily, there are other procedures which honor TYPE=CORR datasets as input. The documentation (TYPE=CORR Data Sets) mentions PROC REG among others. This is fortunate because PROC REG is capable of computing partial correlations: see this PharmaSUG 2010 paper.
First, I create a new correlation dataset from your dataset TEST with renamed variables because a TYPE=CORR dataset created with PROC CORR would contain the variables whose names are listed in variable _NAME_. Then I use PROC REG with the PCORR2 option of the MODEL statement (as suggested by the paper) to compute the square of the desired partial correlation coefficient and the corresponding p-value. Finally, I apply the SQRT function to obtain the partial correlation coefficient (variable PARTCORR).
data have(type=corr);
set test;
rename x1=SP x2=EFB_POST x3=SPR x4=EFR x5=ECFA x6=HGC x7=NLT x8=EFB_PRE;
run;
ods output ParameterEstimates=est;
proc reg data=have plots=none;
model SP=EFB_POST SPR EFR / pcorr2;
quit;
data want;
set est;
where dependent='SP' & variable='EFB_POST';
partcorr=sqrt(SqPartCorrTypeII);
keep dependent variable partcorr probt;
run;
proc print data=want;
run;
Here is another example using dataset FISH1 from the PROC CORR documentation: Example 2.6 Computing Cronbach’s Coefficient Alpha. I used this to compare the results from PROC REG (as above) to the results from PROC CORR with the PARTIAL statement (obtained from the original data rather than a TYPE=CORR dataset).
data fish1c;
set fish1;
if weight; /* remove an observation with a missing WEIGHT value */
run; /* 34 obs. */
ods output PartialPearsonCorr=ppc;
proc corr data=fish1c;
var Height Width;
partial Length3 Weight3;
run;
proc print data=ppc;
format _numeric_ best12.;
run;
proc corr data=fish1c outp=corrmat noprint;
var Height Width Length3 Weight3;
run;
ods select none;
ods output ParameterEstimates=parest;
proc reg data=corrmat plots=none;
model Height=Width Length3 Weight3 / pcorr2;
quit;
ods select all;
data target;
set parest;
where dependent='Height' & variable='Width';
partcorr=sqrt(SqPartCorrTypeII);
keep dependent variable partcorr probt;
run;
proc print data=target;
format partcorr probt best12.;
run;
If you compare the two PROC PRINT outputs, you'll see that both the partial correlation coefficient and the corresponding p-value in dataset TARGET (obtained from the TYPE=CORR dataset using PROC REG) are equal (at least after rounding to 10 decimal places) to the results from PROC CORR in dataset PPC.
... View more