BookmarkSubscribeRSS Feed
Fluorite | Level 6

Dear team,


We are creating password protected .pdf file by using SAS ODS. The size of pdf do vary, like some time pdf file having 2 pages , some time 3,4 and 5 pages.

I want to add images in the last page of password protected pdf file.


Kindly assist !!


Thanks in Advance..



Sukhbir Singh

Mob: 95 82 85 38 56

Moved to the ODS forum, where is will likely get seen by folks with more experience in this area. Also, it would be helpful to explain what type of images you are adding to the PDF - are the images being generated by SAS (using SAS/Graph or the SG procedures) or are they some king of external image file located elsewhere on disk?
Check out my Jedi SAS Tricks for SAS Users
Hi: If you use PROC REPORT, look at the example on page 11 of this paper . I'm not sure how many images you have, but using COMPUTE AFTER would allow you to insert an image on the last page of your report. The example on page 11 shows both COMPUTE BEFORE (top of report) and COMPUTE AFTER (bottom of report/last page).
That might be one way to get started. But it does depend on what kind of image you want to insert and how they were created.

Calcite | Level 5

Hi Cynthia,


Thanks for your response!!


I have applied in my code but it is not working. below is the sample code:

ods pdf text="~{newline 5}~S={JUST=C FONT_SIZE=12pt color=maroon }~{nbspace 75}* Account Summary *";
proc report data=temp1_0600
style(report)=[cellspacing=1 borderwidth=1 bordercolor=maroon textalign=c]
style(header)=[fontfamily="Abadi Extra Light" fontsize=1 Color=white textalign=c backgroundcolor=maroon]
style(column)=[fontfamily="Abadi Extra Light" fontsize=1 textalign=c ];
define OPENING_BALANCE/'Opening Balance(INR)' display style(column)={cellwidth=1.5in just=right};
define TOT_DEBIT_AMT/'Total WithDrawals(INR)' display style(column)={cellwidth=1.7in just=right};
define TOT_CREDIT_AMT/'Total Deposits(INR)' display style(column)={cellwidth=1.5in just=right };
define CLOSING_BALANCE/'Closing Balance(INR)' display style(column)={cellwidth=1.5in just=right};
define TRAN_COUNT/'No. Of Transaction' display style(column)={cellwidth=1.5in just=right};
where ACC_NO="&ac";
/*compute after _page_ /style ={background=white preimage="/tmp/ippb1.jpg"};*/



Sukhbir Singh

95 82 85 38 56


Hi: If you look at my example, I used preimage in a different way. The COMPUTE block has to write SOMETHING -- preimage applies to the text that's being inserted into the COMPUTE block area. The text can be a text string, as I show in the paper. Or, the text can be a space. But the COMPUTE block area has to have something in it. That's why I have a LINE statement that writes a space into the COMPUTE area. This worked for me in PDF, as you can see below:



  I had my image in the c:\temp\output folder and that's the folder where I wrote the PDF file too. Here's the code I ran:

options topmargin=.75in bottommargin=.75in rightmargin=.25in leftmargin=.25in;

*** assumes that image and file are stored in same &OUTPATH folder;
*** image stored in c:\temp\output folder;
%let outpath=c:\temp\output;

ods pdf(id=px1) file="&outpath\example_COMPUTE_AFTER_PAGE.pdf";

proc report spanrows;
  where region in ('Asia' 'Canada') and
        product in ('Boot' 'Sandal' 'Slipper');
  title 'Ex 2b) COMPUTE AFTER with image';
  column region product sales returns Profit inventory PctInv ;
  define region / group;
  define product / group;
  define profit / computed f=dollar14.;
  define pctinv / computed f=percent9.2;
  break after region/summarize;
  rbreak after / summarize;
  compute pctinv;
    profit = sum(sales.sum,-1*returns.sum);
    pctinv = sales.sum / inventory.sum;
  compute after  / style={background=white preimage="&outpath\shoe_zoo.png"};
     line ' ';

ods pdf(id=px1) close;

My code uses SASHELP.SHOES so you should be able to run it. I put the shoe_zoo.png file inside a zip archive (since the forum would not allow a PNG file to be attached to the post). You'll have to unzip and store the image file in the same location. Without data no one can test your code, so this is something for you to try. As you see from my screen shot, the COMPUTE after with an image worked for me in PDF. It should work for you. If not, you may want to open a track with Tech Support.


Also, I would recommend that you experiment with both the COMPUTE AFTER, and the COMPUTE AFTER _PAGE_ to see which one works with your data to put the image on the last page.





Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.


Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 4 in conversation