|
|
|
||||
|
|
|||||
data test; input age x y ; cards; 10 3 5 15 3 9 20 4 8 22 4 8 25 8 3 ; run; * get partial correlation, it is -.94 ; proc corr data=test; var x y ; partial age; run; * get residual for y , save in test2; proc reg data=test; model y = age; output out=test2 r=yresid; run; * get residual for x (using test2), save in test3 ; proc reg data=test2; model x = age; output out=test3 r=xresid; run; * show data ; proc print data=test3; run; * do corr on "xresid" and "yresid" ; * this works out to be -.94 ; proc corr data=test3; var xresid yresid; run;
* You can then plot "xresid" and "yresid" to ; * see the relationship between x and y, after ; * partialing out "age" ;
UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services