BookmarkSubscribeRSS Feed
christyh
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?

Thanks
4 REPLIES 4
Cynthia_sas
SAS Super FREQ
Hi:
The footnote statement supports the LINK= option, that tells ODS how to build a hyperlink in your footnote. For example, if you did this:
[pre]
footnote link='http://www.setgame.com' "Play SetGame";
[/pre]

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

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:
[pre]
<a target="new" href="http://your.midtier.server:8080/SASStoredProcess/do?_program=/STP_Orion/MyReport">
Run the Shoe Report</a>
[/pre]

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:

[pre]
%global usrchoice;
*ProcessBody;
%let _odsdest = &usrchoice;
%stpbegin;
. . .more code . . .
%stpend;
[/pre]

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).

cynthia
Vince_SAS
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


SAS R&D

 



[pre]
%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>";
%end;

%mend setup;

%SETUP;

title 'Student Information by Gender and Age';
&MY_FOOTNOTE;

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;
[/pre]
christyh
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?
Vince_SAS
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
SAS R&D

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 1731 views
  • 0 likes
  • 3 in conversation