简体   繁体   中英

PDF macro in SAS

I have written a macro which takes multiple datasets and the variables common with those datasets and generates a frequency table using proc freq, as follows:

%macro f(input= , vars= );
  %let n_d=%sysfunc(countw(&input));
  %do i = 1 %to &n_d;
     %let dataset = %scan(&input, &i);
     %let n=%sysfunc(countw(&vars));
     %do j = 1 %to &n;
        %let values = %scan(&vars, &j);
        title "Frequency of &dataset and &values";
        proc freq data = &dataset;
          tables &values/nocum;
        run;
     %end;
  %end;
%mend;

I work with UNIX SAS and my version of SAS doesn't have access to HTML output because of some network issues.

I want to create a pdf output and for each of the above frequency tables and store it either in a single pdf or in a multiple pdf's(not too particular on that). Please help!!

You can sandwich the code between ODS PDF file='' and ods pdf close . Where you place the code determines if you get a single or multiple files.

For example, to generate a single file, put it at the outmost loop:

%macro f(input= , vars= );
ods pdf file="myoutout.pdf" style=meadow;
  %let n_d=%sysfunc(countw(&input));
  %do i = 1 %to &n_d;
     %let dataset = %scan(&input, &i);
     %let n=%sysfunc(countw(&vars));
     %do j = 1 %to &n;
        %let values = %scan(&vars, &j);
        title "Frequency of &dataset and &values";
        proc freq data = &dataset;
          tables &values/nocum;
        run;
     %end;
  %end;
  ods pdf close;
%mend;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM