Your SAS programs, embedded in web apps and elsewhere

ODS to HTML with buttons for PDF and Excel without Requerying data

Reply
Contributor
Posts: 33

ODS to HTML with buttons for PDF and Excel without Requerying data

I have a table I created from a stored process that outputs to html via ods. Attached to the html are two buttons (one for downloading the table as pdf and the other excel).

 

I am looking for a way to query the data once and somehow save the pdf/excel output until the user clicks the pdf/excel button. My current solution is to query the data twice - once on page load to show the HTML table and again in a separate stored process when the user clicks the pdf/excel button.

 

Basically I want to generate the pdf and excel downloadable documents on initial page load but don't give them to the user until button click.

 

Here is some pseudo code using some jquery.

 

proc sql;
    some query
quit;

ods html body=_webout;

ods html text="
<script> $('#printPDF').click(function(){ Requery data in a separate stored process }); $('#printExcel').click(function(){ Requery data in a separate stored process }); </script> <button id='printPDF'>Print PDF</button> <button id='printExcel'>Print Excel</button>"; /* output html table */ proc report data=mydata; run;
SAS Super FREQ
Posts: 304

Re: ODS to HTML with buttons for PDF and Excel without Requerying data

 

Here's an old document that may be helpful:

 

Sample 26165: Generating Multiple Output Types at Once Using SAS/IntrNet

http://support.sas.com/techsup/notes/v8/26/165.html

 

It was written for SAS/IntrNet but you should be able to adapt it for use with a stored process.

 

Vince DelGobbo

SAS R&D

 

 

Contributor
Posts: 33

Re: ODS to HTML with buttons for PDF and Excel without Requerying data

[ Edited ]
Posted in reply to Vince_SAS

Thanks Vince. That example mirrors very closely to what I want to do. I wonder how this works when multiple users are accessing the stored process at the same time. Will this 'lightweight' session be unique to each user?

 

I think I might just do this all on the front end without SAS using some javascript libraries.

SAS Super FREQ
Posts: 304

Re: ODS to HTML with buttons for PDF and Excel without Requerying data

The session is unique to each user.  If you don't use sessions and instead store files in some other location accessible to the browser, then you need to consider cleanup and access issues.

 

See also _OUTPUTAPP and _CONTDISP:

 

Using the REPLAY Program

http://support.sas.com/documentation/cdl/en/dispatch/64895/HTML/default/viewer.htm#replay.htm

 

Using reserved Macro Variables

http://support.sas.com/documentation/cdl/en/stpug/68399/HTML/default/viewer.htm#p184mqqbi9w6qjn1q061...

 

Ask a Question
Discussion stats
  • 3 replies
  • 315 views
  • 0 likes
  • 2 in conversation