Hi Sas Experts,
Is there is any way to add word documents as my coverpage in ods pdf. Please help.
- display your coverpage pdf in a pdf viewer
- use your favorite imaging tool (I recommend irfanview) to do a screenshot of the pdf
- save as .jpg
- use that as preimage
No, not directly. The reason being is that the Word document needs to be converted to a PDF - requiring licenses for the both of them, hence its outside the remit of a SAS topic. You could of course script (VB/VBA, PDF javascript) a process where the PDF output is combined with the output of printing to PDF from Word.
Word can print or save to PDF
If you have Adobe professional you can append the PDF files.
You can use SAS to manage these tasks but the activity does occur elsewhere.
Hi Reeza,
As you suggested i have converted the word to pdf and used in my progrm. But am getting the error. Please help
Below is the error:
Error: Unable to load image C:\temp\test.pdf; default image will be used instead
Following is my code
ods pdf file='path.pdf' notoc startpage=no color=full style=colorramp;
ods pdf text='^{style[preimage="C:\temp\test.pdf"}';
ods pdf startpage=now;
goptions hsize=3.99 in vsize=4.2 in;
proc print data=sashelp.class;
goptions horigin=0 in vorigin=4 in;
run;
proc means data=sashelp.class;
goptions horigin=4.25;
var height;
run;
ods pdf close;
Hi RW9,
As you suggested i have converted the word to pdf and used in my progrm. But am getting the error. Please help me
Below is the error:
Error: Unable to load image C:\temp\test.pdf; default image will be used instead
Following is my code
ods pdf file='path.pdf' notoc startpage=no color=full style=colorramp;
ods pdf text='^{style[preimage="C:\temp\test.pdf"}';
ods pdf startpage=now;
goptions hsize=3.99 in vsize=4.2 in;
proc print data=sashelp.class;
goptions horigin=0 in vorigin=4 in;
run;
proc means data=sashelp.class;
goptions horigin=4.25;
var height;
run;
ods pdf close;
If your SAS process runs on a remote server, it can't see your local C: drive.
How is your SAS environment set up?
Hi KurtBremser,
My SAS set up is on local server
Edit: Also note you have a typo in your code:
ods pdf text='^{style[preimage="C:\temp\test.pdf"}';
There is no closing ]
Sorry, that is not what I suggest. Yes, the Word file needs to be sent to PDF, using a method there - e.g print to file from Word. But the combination still does not happen in SAS. Adobe has its own Combine PDF feature that you would use (assuming you have that software). The option in SAS preimage is for adding a picture to the document, not for combining PDF's.
As I mention above, this is using PDF/Word technology, and is not for SAS. Search google for "vb combine pdf files", there are many examples. The flow would look something like:
SAS Word
Create PDF Create PDF
PDF
Combine PDFs
For non-programmers you can mouse surf a solution using libreoffice.
LibreOffice can also convert MS Office docs to PDF and append them.
You only need gswin64c.exe from open source ghostscript.
HAVE
d:/pdf/class.pdf
d:/pdf/cars.pdf
WANT APPEND CARS.PDF TO CLASS.PDF
d:/pdf/classcars.pdf
SOLUTION
ods pdf file="d:/pdf/class.pdf";
proc print data=sashelp.class;
run;quit;
ods pdf close;
ods pdf file="d:/pdf/cars.pdf";
proc print data=sashelp.cars(obs=20);
run;quit;
ods pdf close;
x "cd d:\pdf";
x "C:\Progra~1\gs\gs9.19\bin\gswin64c.exe -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=classcars.pdf -dBATCH class.pdf cars.pdf";
11 ods pdf file="d:/pdf/class.pdf";
NOTE: Writing ODS PDF output to DISK destination "d:\pdf\class.pdf", printer "PDF".
12 proc print data=sashelp.class;
13 run;
NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.05 seconds
user cpu time 0.00 seconds
system cpu time 0.03 seconds
memory 656.25k
OS Memory 13796.00k
Timestamp 09/13/2016 05:08:00 AM
Step Count 10 Switch Count 0
13 ! quit;
14 ods pdf close;
NOTE: ODS PDF printed 1 page to d:\pdf\class.pdf.
15 ods pdf file="d:/pdf/cars.pdf";
NOTE: Writing ODS PDF output to DISK destination "d:\pdf\cars.pdf", printer "PDF".
16 proc print data=sashelp.cars(obs=20);
17 run;
NOTE: There were 20 observations read from the data set SASHELP.CARS.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.07 seconds
user cpu time 0.07 seconds
system cpu time 0.00 seconds
memory 1186.53k
OS Memory 14564.00k
Timestamp 09/13/2016 05:08:01 AM
Step Count 11 Switch Count 0
17 ! quit;
18 ods pdf close;
NOTE: ODS PDF printed 2 pages to d:\pdf\cars.pdf.
19 x "cd d:\pdf"
19 ! ;
20 x "C:\Progra~1\gs\gs9.19\bin\gswin64c.exe -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=classcars.pdf -dBATCH class.pdf cars.pdf"
20 ! ;
Hi ,
Thank you very much for your help, but I dont have multiple pdfs , I have one word doc which is converted to pdf.
I want to use this pdf as my cover page, and rest of the pdfs I will generate by using sas.
Basically It looks like the below code, in the ods pdf text statement am referring to the coverpage pdf.
ods pdf file='path.pdf' notoc startpage=no color=full style=colorramp;
ods pdf text='^{style[preimage="C:\temp\test.pdf"}';
ods pdf startpage=now;
goptions hsize=3.99 in vsize=4.2 in;
proc print data=sashelp.class;
goptions horigin=0 in vorigin=4 in;
run;
proc means data=sashelp.class;
goptions horigin=4.25;
var height;
run;
ods pdf close;
Below is the error:
Error: Unable to load image C:\temp\test.pdf; default image will be used instead
- display your coverpage pdf in a pdf viewer
- use your favorite imaging tool (I recommend irfanview) to do a screenshot of the pdf
- save as .jpg
- use that as preimage
I think your missing the fundamental point here. PDF is not a SAS technology, it is owned by a separate company - Adobe. To convert information from other file types to PDF requires a converter. There is a convertor built into Word so you can print Word files to PDF. There is a PDF creator built into SAS ODS (the bit that creates reports). Neither of these provide "merging" functionality, you need third party software to do this, be it LibreOffice, Adobe etc. You cannot do it in SAS (unless you want to convert it to an image as @Kurt_Bremser suggested).
Yes Thats now I got it.
Thank you
Do you have Adobe Pro? If so, see the methods used here:
http://analytics.ncsu.edu/sesug/2011/BB15.Welch.pdf
You have multiple PDF files, the first page plus the SAS output.
You coukd try to create the first page as a PNG image and use the insert method your attempting.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.