Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Including syntax in SAS ODS pdf file

Tags:

sas

sas-ods

Is it possible to include submitted syntax or even output of log file when ODS into a PDF using SAS?

For instance, give this simple code:

ods pdf file = "c:\temp\myPDF.pdf";
proc reg data = mydata;
model y = x;
run;
ods pdf close;

I can get the regression output and accompanying graph fine. But is it possible to incorporate into PDF the enclosed command like this?

proc reg data = mydata;
model y = x;
run;
like image 610
Penguin_Knight Avatar asked Oct 10 '14 18:10

Penguin_Knight


1 Answers

It is, but it requires a couple of hoops. Luckily, you could wrap this into macros to clean up your code.

  1. Create a temporary fileref to hold your log.
  2. Start your PDF and output the log to the fileref.
  3. Write code.
  4. Stop writing log to fileref.
  5. Print file contents to PDF using ODF TEXT=

Hope this helps

filename x temp;

ods pdf file="c:\temp\temp.pdf";
title "Cost of Power";
options source;
proc printto log=x;
run;

proc reg data=sashelp.cars;
model msrp = horsepower;
run;
quit;

proc printto;run;

title;
ods pdf startpage=now; /*Force a new page in the PDF*/

data _null_;
infile x;
input;
call execute("ods text='LOG: "||_infile_||"';");
run;

ods pdf close;

filename x ;
like image 127
DomPazz Avatar answered Nov 09 '22 23:11

DomPazz