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.
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='http://www.setgame.com' "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: http://support.sas.com/kb/23/342.html
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:
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).
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.
%if (%upcase(%qcmpres(&_ODSDEST)) ne PDF) %then %do;
%let MY_FOOTNOTE=footnote "<a href=""&_URL.?_program=&_PROGRAM%nrstr(&_odsdest=PDF)"">Download PDF file</a>";
title 'Student Information by Gender and Age';
proc sort data=sashelp.class out=class; by sex age; run; quit;
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?
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.