Search code examples
sassas-ods

SAS ODS Output: Get Histogram (only!) in PDF


I'm running the following code to output a histogram of a certain variable:

    ods results off;
    ods listing close;
    ods pdf file="&folder/temp.pdf";
    title ;
    * Histogram of betCount;
    proc univariate data=want;
          var BetCount;
          histogram;
    *label sex=' ' height='Height (cm)';
    run;
    ods pdf close;
    ods listing;
    ods results on;

It does create a PDF, but there's lots of extra tables and output. I just want to see the histogram only, as I'm read into latex as part of a \minipage with six figures in it. I have done this manually before by taking a screenshot of the required region, pasting into Paint and coverting to PDF or PNG: I don't want to go down that road again! How can this be done in general for graphs and plots in SAS?

Thanks for any help at all.


Solution

  • You can name the graph and then use ODS SELECT to select (only) it. (ODS TRACE ON will help you see it in the log.)

    ods trace on;
    ods pdf file="c:\temp\myfile.pdf";
    ods select histogr;
    proc univariate data=sashelp.class;
    var age;
    histogram age/name="Histogr" ;
    run;
    ods pdf close;