Wednesday, June 6, 2012

To select desired outputs in one PDF file


Recently, I was asked to generate a series of correlation coefficient plots (Scatter Plots). I put them in one big PDF file. Basically, the codes are like:

ods pdf file="***.pdf";
... codes for generating plots ...
ods pdf close;

Today, I was asked to add p-Values in those plots. To get p-Values, I have to use “ODS OUTPUT” (true?) to catch it by “PROC CORR”. The codes are like below:

ods output PearsonCorr=out1;
proc corr data=dataset_name PEARSON;
var x y;
run;
ods output off;

Basically, I just want the p-Value in dataset out1 from "ods output". After I add the codes, the outputs of “PROC CORR” are added to the PDF file. ouch!

Maybe, I used wrong terms. I could not find any answer from google to solve the issue. I turned back to SAS help. After researches and tests, I found a solution: adding “ods pdf exclude/select;”  to turn off/on the outputs in the PDF file. 

So the codes are like below (highlighted in light-green):

ods pdf file="***.pdf";
... codes for generating plots ...

ods pdf exclude all;
ods output PearsonCorr=out1;
proc corr data=dataset_name PEARSON;
var x y;
run;
*ods output off;
ods pdf select all;
... codes for generating plots
ods pdf close;

"PROC CORR" outputs are not shown in the pdf file. It works perfectly well.

No comments:

Post a Comment