Help using Base SAS procedures

Export to a PDF from SAS

Reply
N/A
Posts: 0

Export to a PDF from SAS

Hi All,

I was wondering if there is a way to export a file to a PDF format from SAS,

if there is, whats the best way to do it?

I use Enterprise Guide.

regards
Trusted Advisor
Posts: 2,113

Re: Export to a PDF from SAS

I guess the question back is what do you want to do with it afterward. You could just select the PDF as the print device and do a data set listing task. That does what you asked, but may not be what you need.
N/A
Posts: 0

Re: Export to a PDF from SAS

thanks for your reply Doc, there are about 35 users in the data set that is used, to create a PDF via printer would take a long time.

regards
SAS Super FREQ
Posts: 8,743

Re: Export to a PDF from SAS

Hi:
It depends on what you mean by "export a file to PDF format". You could mean export a SAS dataset; you could mean export a SAS/Graph file; you could mean export the results of running an Enterprise Guide Task (such as the List Data task or the Summary Tables task).

Depending on which version of Enterprise Guide that you have, you should be able to "turn on" the creation of PDF output. In EG 4.2, you can do it by following this click path:
Tools --> Options
--> when the Options Window opens, select "Results General" in the left-hand pane
--> in the area entitled, "Results Formats" on the right-hand side, you can de-select SASReport and instead, select PDF as a choice
-->When you create output from tasks and wizards, including Graph tasks, your output will go to a PDF file(s)

Alternately, you can use code to send output to the Output Delivery System PDF destination by opening a code node or program node in EG and using program code, such as:
[pre]
ods _all_ close;
ods pdf file='c:\temp\output_files.pdf';
proc print data=sashelp.class;
title 'Class Data';
run;

proc gchart data=sashelp.class;
vbar sex / sumvar=weight type=mean;
title 'Average Weight by Gender';
run;
ods pdf close;
[/pre]

cynthia
N/A
Posts: 0

Re: Export to a PDF from SAS

Thanks for your responses to my post,

What I'm trying to do is, I have a data set where it has information pertaining to different users,

I'm trying to group all records for each user to email them on a daily basis.

Its more like MI for each of the users, the total number of users are about 35.

I will try your code and the other suggestions.

regards
SAS Super FREQ
Posts: 8,743

Re: Export to a PDF from SAS

Hi:
That extra bit of information (that you want to email a PDF to each user) would have been helpful information. You -can- do emails using SAS and ODS (and also from within EG) -- but I only know the code way to send emails.

For example, there are 19 students in the file SASHELP.CLASS, if I wanted to send email to just one of the students (Alfred), I could do this:
[pre]
** 1) Create Report for Alfred;
ods pdf file="c:\temp\Alfred.pdf";
proc print data=sashelp.class;
title "Records for Alfred";
where name="Alfred";
run;
ods pdf close;
title;

** 2) Email PDF file as an attachment;
filename mail_att email
to="Alfred@somecompany.com"
from="A.Programmer@otherplace.net"
subject='send PDF file'
attach="c:\temp\Alfred.pdf";

data _null_;
file mail_att;
put "Dear Alfred:";
put "Here are all your records for today.";
run;

filename mail_att clear;
[/pre]

So the above example (assuming all the configuration stuff was set up correctly on the SAS server) would email the PDF file to Alfred. If I wanted to send the same type of email to every person in SASHELP.CLASS (assuming I knew their email addresses or had their email addresses in a file), I could wrap code similar to the above in a SAS macro program and send an email to every person in SASHELP.CLASS.

Depending on your level of programming expertise or SAS macro experience, you might want to use an approach like the above, or you might want to investigate a way to build an EG project that would send emails. For an EG point and click solution (if there is one), you might want to post your question in the Enterprise Guide forum for help from folks who use EG a lot.

cynthia
Occasional Contributor
Posts: 15

Re: Export to a PDF from SAS

Dear Cynthia!

My name is Andrey, I'm write here because I think that my question is the same or near with WickWickey's question.

Could you please help me, I look for the "out2pdf" macro similar to "out2rtf" macro that shared here: http://support.sas.com//rnd/base/ods/templateFAQ/out2rtf.sas.

Does the "out2pdf" macro exist?

Thank you!

Best Regards,

Andrey

SAS Super FREQ
Posts: 8,743

Re: Export to a PDF from SAS

Hi:

  First, it's not a good idea to tack your new post onto a 5 year old track. Usually, I don't look at old ones.

   

  Second, if you look at the comment block at the top of the code, you will see 2 things: 1) this macro program was not written by SAS; 2) this is a VERY old program -- 13 years old since the last revision -- and to some extent, people no longer use macro programs like this, instead, they use ODS RTF, ODS PDF to write RTF and PDF files.

/*------------------------------------------------------------------------------

Program: out2rtf.sas Author: David Ward (dward@internext-inc.com)

Created: 05/1999 Revised: 11/2002

Description: Convert text-based output from *.lst files or the

output window to raw RTF

Notes: The in parameter can either be: - _OUTPUT_ (default): output window - physical file

reference: i.e. c:\temp\output.lst - all files matching by extension: i.e. *.lst, *.out This macro does not support complex

pattern matching like dem*.lst

The out parameter can either be: - a directory (mandatory for *.lst notation) - a file

reference (if you want an RTF file with a different prefix than your listing file) If your listing file has no pagebreaks

you have to specify the pagesize so we can insert RTF pagebreaks at the right places

Revision: 11/4/2002 DW

------------------------------------------------------------------------------*/

    

  It doesn't make sense that there would be an equivalent type of program for PDF. An RTF file is an ASCII text file, the RTF control strings are inserted around your text and then a Word processor that knows how to interpret RTF strings can display the text inside the Word processor. The RTF specification was originally written by Microsoft Word. The reason that ODS RTF has replaced a macro program like this is that with ODS RTF, you don't have to worry about the RTF control strings or make a LISTING file first. You can directly send output from your procedure directly to an RTF file.

  A PDF file on the other hand is a proprietary (BINARY) file format that belongs to the Adobe company. A PDF file is NOT an ASCII text file, there are NOT control strings used in the creation of a PDF file, so you must use something like ODS PDF in order to make a PDF output file from your SAS procedure output.

  If you need help learning how to use ODS , please review the documentation and/or open a track with Tech Support.

cynthia

Ask a Question
Discussion stats
  • 7 replies
  • 15808 views
  • 0 likes
  • 4 in conversation