BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
StevePfromAZ
Fluorite | Level 6

I'm using SAS 9.4 on Windows Server 2008, I'm trying to replace an existing MS Sharepoint reporting portal (displays static excel and html files as well as executes SAS macro's for dynamic content) and was looking at the Stored Process Web Application as a possible repleacement. Can't figure out how to display a static HTML page that was created by a SAS batch process. I added the file to the Mgt. Console folder structure, but don't see it in the Web Application. Looks like it only displays Stored Proc's. Any suggestions are appreciated, I would like to use this existing reporting structure to execute my SAS macro's (as stored proc's).

1 ACCEPTED SOLUTION

Accepted Solutions
Quentin
Super User

Hi,

Yes, I think we're on the same page.

So you want to display UnitGeneration.html.  Assume that file is on your Windows server, in C:\Reports\UnitGeneration.html.

You make a stored process, call it ShowUnitGeneration.  The stored process will have no prompts.

The source code of the stored process will be:

%macro BinaryFileCopy ;

%* macro code is available from the sasdummy post I cited;

%mend %BinaryFileCopy;

%macro streamfile;

%*macro code as I posted it above;

%mend streamfile;

%streamfile(file=C:\Reports\UnitGeneration.html)

The stored process source code should not use %stpbegin/%stpend, because we are writing to _webout ourselves.  The stored process must produce streaming results (not package results).

That set up should (I'm pretty sure : ) do what you want.  I did some quick testing, since I hadn't actually used %BinaryFileCopy before.

In SPWA you can navigate to the metadata folder where the stored process is.  So you will see the stored process name in the left pane (ShowUnitGeneration). And when you click the stored process name (link), the stored process will run (because there are no prompts), and results will be displayed in the right pane.  And the results will be UnitGeneration.html.

So it's not a simple <a h r e f> </ a> hyperlink in the left pane which links to UnitGeneration.html.  It's an actual stored process, but all the stored process does is stream UnitGeneration.html to _webout.

Sound reasonable/feasible?

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.

View solution in original post

7 REPLIES 7
Quentin
Super User

HI,

I'm a bit confused by your questions.

Not sure what you mean when you say you added a static html file to the SAS Mgt Console folder structure.  An html file is a file that sits on a file server.  The SMC folder structure is metadata, containing logical objects (stored processes, DI jobs, prompts) that are defined in SAS metadata.

THe stored process web app is used to run stored processes.

If you have an html file you want to display and use as a portal, you can just move the html file to your web server.  You can have links from that html page to the SPWA, where you call a stored process via the URL.  So the URL looks like href="h t t p ://MyServer:Port/SASStoredProcess/do?&_program=/MyStoredProcesses/MonthlyReport"

/MyStoredProcesses is a metadata folder, containing a stored process named MonthlyReport.  When someone clicks the link, the stored process will run (generating the montly report).

If you are saying you already have MonthlyReport.htm (or MonthlyReport.xlsx) sitting on your server, and you want a stored process which will display the file, yes, you could have a stored process which reads in an html file (or excel file) and streams it to _webout.  So when a user runs the stored process, they will see the web page (or get a dialog box to download/open the Excel file).

HTH,

--Q.

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
StevePfromAZ
Fluorite | Level 6

Hi Quentin, yes the html and .xlsx files already exist (created outside the SAS realm) and I want to have a "link" that either displays the html/xlsx contect or as you mention a ssp that will stream to _webout. Any examples would be greatly appreciated.

Thank you.

Quentin
Super User

Hi,

re streaming a file to _webout, Chris Hemedinger had a great blog post a few months ago where he shared a %BinaryFileCopy() macro written by Bruno Muller:

http://blogs.sas.com/content/sasdummy/2013/09/17/copy-file-macro/

In a stored process, you can use that macro to copy a file to _webout.  Below is an example (not very well tested).  Key point is that the stored process needs to create streaming results (not package results), and you do not want %STPBEGIN/%STPEND in the stored process code.

%macro streamfile(file=);
%local type;
filename _in "&file";

%*get extension;
%let type=%upcase(%scan(&file,-1,.));

%*if the file is not .HTML, need to tell the browser its an attachment to download;
%if &type ne HTML %then %do;
  data _null_;
    %if &type=RTF %then %do;
      rc = stpsrv_header('Content-type','application/msword');
    %end;
    %else %if &type=PDF %then %do;
      rc = stpsrv_header('Content-type','application/pdf');
    %end;
    %else %if &type=XLS or &type=XLSX %then %do;
      rc = stpsrv_header('Content-type','application/vnd.ms-excel');
    %end;
     rc = stpsrv_header('Content-disposition',"attachment; filename=%scan(&file,-1,/\)");
  run;
%end;


%binaryFileCopy(
  infile=_in
 ,outfile=_webout
  )

filename _in clear;

%mend streamfile;

%streamfile(file=/somewhere/MyExcel.xls)

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
StevePfromAZ
Fluorite | Level 6

Hi Quentin, I appreciate the replies, but this is not what I'm looking to accomplish. I'm probably not explaining very well and maybe the SSPWA is not capable, but I have .html files created in the wee hours with SAS batch jobs (long running jobs), i.e. UnitGeneration.html. I'd like to be able to have a link in the folder structure of the SSPWA that displays/calls the UnitGeneration.html file and displays in the right pane of the web application. Is this doable, calling an already created html file?

Steve

Quentin
Super User

Hi,

Yes, I think we're on the same page.

So you want to display UnitGeneration.html.  Assume that file is on your Windows server, in C:\Reports\UnitGeneration.html.

You make a stored process, call it ShowUnitGeneration.  The stored process will have no prompts.

The source code of the stored process will be:

%macro BinaryFileCopy ;

%* macro code is available from the sasdummy post I cited;

%mend %BinaryFileCopy;

%macro streamfile;

%*macro code as I posted it above;

%mend streamfile;

%streamfile(file=C:\Reports\UnitGeneration.html)

The stored process source code should not use %stpbegin/%stpend, because we are writing to _webout ourselves.  The stored process must produce streaming results (not package results).

That set up should (I'm pretty sure : ) do what you want.  I did some quick testing, since I hadn't actually used %BinaryFileCopy before.

In SPWA you can navigate to the metadata folder where the stored process is.  So you will see the stored process name in the left pane (ShowUnitGeneration). And when you click the stored process name (link), the stored process will run (because there are no prompts), and results will be displayed in the right pane.  And the results will be UnitGeneration.html.

So it's not a simple <a h r e f> </ a> hyperlink in the left pane which links to UnitGeneration.html.  It's an actual stored process, but all the stored process does is stream UnitGeneration.html to _webout.

Sound reasonable/feasible?

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
StevePfromAZ
Fluorite | Level 6

Nice, that worked very well.

I can now combine dynamic content in with static content on the SPWA.

Thank you.

DonH
Lapis Lazuli | Level 10

You should also check out the SAS autocall filesv macro/program. Here is a link to the doc for it:

FILESRV Program

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 4039 views
  • 0 likes
  • 3 in conversation