BookmarkSubscribeRSS Feed
Calcite | Level 5
Hi there,

I'm trying to do the following and need some ideas on how to do it:

I have a stored process (created in EG) that runs a graph and simple report. I want to be able to have a link in the footnote that will basically rerun the report but create a pdf file instead. Ultimately this will go onto the portal and I want people to see the report as html but have the option of clicking on a link (footnote) that will create a pdf file they can print off.

Any ideas?

The footnote statement supports the LINK= option, that tells ODS how to build a hyperlink in your footnote. For example, if you did this:
footnote link='' "Play SetGame";

Then a hyperlink/anchor tag would be built in the resulting HTML by ODS, if you used an HTML based destination to create your output.

But, you could ALSO "hard-code" an HTML form into your ODS output using the POSTHTML style attribute and put a button at the bottom of your report, as described here:

In either case, however, you're not done yet. In order to either use LINK= or code your FORM ACTION, you have to know how to invoke a stored process via URL using the Stored Process Web Application. If you use the button method and choose to use JavaScript, then you also have to worry about whether scripts are enabled for the browsers.

Generally, an anchor tag to invoke a stored process looks -something- like this:
<a target="new" href="http://your.midtier.server:8080/SASStoredProcess/do?_program=/STP_Orion/MyReport">
Run the Shoe Report</a>

Of course, in order to run a stored process via URL, you have to know the name of your midtier server and the port number that you are supposed to use. You have to know the metadata name for the _PROGRAM parameter and you have to know whether the stored process expects any other name/value pairs as parameters.

One issue that you have to deal with is the fact that once you put such a button or a footnote at the bottom of your output, you run the risk of having a stored process that will only work in one or two of the client applications (such as the Portal or EG). It's entirely possible that client applications like Excel or PowerPoint or Web Report Studio might not respect or treat your URL link correctly.

Another approach would be to design a stored process where the type of report desired (HTML or PDF) could be one of the parameters that the user chose. Then, you would need to code in your stored process the destination that corresponded to their choice. To override the default destination for the portal (which is HTML), you can specify an override to the automatic parameter &_ODSDEST -- inside the stored process and before your %stpbegin:

%global usrchoice;
%let _odsdest = &usrchoice;
. . .more code . . .

The stored process documentation and the Stored Process Web Application sample programs have some examples of using forms and invoking stored processes via URL. With the above stored process, you still run the risk of having a stored process that could not execute in PowerPoint or Web Report Studio (since neither of them can handle PDF as a result type), but it may be a more straightforward approach, then making the report contain a hyperlink in the footnote (which you will have to remove when you generate the PDF results).

Rhodochrosite | Level 12
Below is some SAS code to get you started. You will probably want to enhance it to include error checking and handling of other features, such as the ODS style and the SAS/GRAPH device driver. It was tested using the SAS Stored Process Web Application and assumes a streaming stored process that initially creates HTML output.


Create a new Code/Program node in Enterprise Guide and add the code below. Create a streaming stored process and run it from the SAS Stored Process Web Application or the SAS Information Delivery Portal.


Good luck.


Vince DelGobbo



%global _ODSDEST;

%macro setup;

%global MY_FOOTNOTE;

%if (%upcase(%qcmpres(&_ODSDEST)) ne PDF) %then %do;
%let MY_FOOTNOTE=footnote "<a href=""&_URL.?_program=&_PROGRAM%nrstr(&_odsdest=PDF)"">Download PDF file</a>";

%mend setup;


title 'Student Information by Gender and Age';

proc sort data=sashelp.class out=class; by sex age; run; quit;

proc gchart data=class;
vbar3d age / group=sex discrete nozero shape=cylinder;
run; quit;

proc print data=class;
by sex;
id sex;
run; quit;
Calcite | Level 5
Thanks for the suggestions...

I've tried Vince's and I forgot to mention one thing, I'm trying to pass parameters to the stored processes.... it appears that it's running and works but when I click on the pdf link it goes to the first pdf file that was created. Meaning it doesn't seem to rerun the code with the new parameter. Does that make sense to you?
Rhodochrosite | Level 12
My code is passing the parameter _ODSDEST and it is recognized and used.

View the HTML source, locate the bad link, and examine it. Perhaps your SAS code is incorrectly building the URL. If the URL is correct, copy and paste that URL into the address bar of your Web browser and run with _DEBUG=log. Examine the list of global macro variables to make sure they are getting passed through correctly. If that checks out, perhaps your back-end SAS logic is not handling the parameters as you intend.

Good luck.

Vince DelGobbo



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg



Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 4 replies
  • 3 in conversation