The SAS Output Delivery System and reporting techniques

Exporting a data _null_ to a pdf

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 101
Accepted Solution

Exporting a data _null_ to a pdf

Hello,

 

I'm trying to output what is basically just a print out of a formats catalog and two things keep happening:

1.  I cannot for the life of me stop it from printing thousands and thousands of lines in the log.  How do i keep it from writing to the log???  I thought it was ods listing close, (even tried ods _all_ close) but that doesn't appear to do anything at all.

 

2.  I keep getting this in the log.  I have a run statement before ods pdf close. ?:

1031  /****PDF TEST*****/
1032  ods _all_ close;
1033  ods pdf file="&path.AppendixC.pdf";
NOTE: Writing ODS PDF output to DISK destination
      "[path removed for confidentiality]\AppendixC.pdf", printer "PDF".
1034  data _null_;

...

[thousands of lines of crap - no error messages or warnings at all though]

...

1009  ods pdf close;
NOTE: ODS PDF printed no output.
      (This sometimes results from failing to place a RUN statement before the ODS PDF CLOSE
      statement.)

 

 

My code:

ods _all_ close;
ods pdf file="&path.AppendixC.pdf";


data _null_;
    set formats2;
    by sort;
    /*Longest name is 11, Type is 9, Value is 16, Label is 50.*/
    put @1 Name @12 Type @23 Value @37 Label1;
    if label2 ne "" then do;
    put                                @37 Label2;
    end;
    if label3 ne "" then do;
    put                                @37 Label3;
    end;
    if label4 ne "" then do;
    put                                @37 Label4;
    end;
    if label5 ne "" then do;
    put                                @37 Label5;
    end;
run;


ods pdf close;

 

 

Thanks,
Megan


Accepted Solutions
Solution
‎04-06-2016 10:59 AM
Frequent Contributor
Posts: 101

Re: Exporting a data _null_ to a pdf

Yes, thanks.  I ended up getting this to work.  Smiley Happy

 

ods listing close;
ods pdf file="&path.AppendixC.pdf";
proc report data=Formats3 nowd headline headskip wrap;
    column first_name first_type value label;
    define first_name / width=12 "Format Name";
    define first_type     / width=9 "Type";
    define value    / width=16 "Value";
    define label    / width=254 "Label";
run;
ods pdf close;

View solution in original post


All Replies
Esteemed Advisor
Posts: 5,979

Re: Exporting a data _null_ to a pdf

Without a file statement in the data step, put will always write to the log, not the output destination.

 

When creating HTML, I often open the HTML destination with no_bottom_matter, close it, write some text to the file with a data _null_; and file .... mod;, and then reopen the same file in ODS HTML with no_top_matter and mod after the fileref.

Don't know if a similar trick is possible (and makes sense) with ods pdf.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Frequent Contributor
Posts: 101

Re: Exporting a data _null_ to a pdf

[ Edited ]

Thanks.  I added the file line to it and that kept it from writing to the log window, but i still got the same

1097  ods pdf close;
NOTE: ODS PDF printed no output.
      (This sometimes results from failing to place a RUN statement before the ODS PDF CLOSE
      statement.)

 

It did create a pdf, but it wont' open:

Adobe Acrobat DC could not open "AppendixC.pdf" because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded).

 

To create an Adobe PDF document, go to the source application.  Then print the document to Adobe PDF.

 

 

 

 

Esteemed Advisor
Posts: 5,979

Re: Exporting a data _null_ to a pdf

Took a look at the ODS PDF documentation. You cannot manually write additional data to a PDF destination like you can with the HTML destination.

So, data _null_ is out, and you must create your output with the proper procedures (proc print, proc report, the graphic procedures, or proc sql with a select) when writing to the PDF destination.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Frequent Contributor
Posts: 101

Re: Exporting a data _null_ to a pdf

Ok, thanks.  Back to the drawing board!!  Smiley Happy

Grand Advisor
Posts: 9,747

Re: Exporting a data _null_ to a pdf

From I can see you are attempting it may be that reshaping your data and proc report would work. A hint: if you want to see different variables in the same column in output that you want to transpose data creating a different variable whose values become the column enteries.

 

Your example I think would work with Proc Report with Name Type and Value as Group variables.

 

 

Solution
‎04-06-2016 10:59 AM
Frequent Contributor
Posts: 101

Re: Exporting a data _null_ to a pdf

Yes, thanks.  I ended up getting this to work.  Smiley Happy

 

ods listing close;
ods pdf file="&path.AppendixC.pdf";
proc report data=Formats3 nowd headline headskip wrap;
    column first_name first_type value label;
    define first_name / width=12 "Format Name";
    define first_type     / width=9 "Type";
    define value    / width=16 "Value";
    define label    / width=254 "Label";
run;
ods pdf close;

Trusted Advisor
Posts: 1,114

Re: Exporting a data _null_ to a pdf

Great that you found a solution.

 

Remark:  You can write to the PDF destination using a data _null_ step: Just add

file print;

to the data step in order to redirect the output from the log to the output destination (which is the PDF file after the ODS PDF and ODS listing close statements).

Frequent Contributor
Posts: 101

Re: Exporting a data _null_ to a pdf

That did work too, thanks!

Post a Question
Discussion Stats
  • 8 replies
  • 542 views
  • 0 likes
  • 4 in conversation