Creating a PDF, CSV or RTF file when running the SAS® Stored Process Server


When running the SAS Stored Process Server it is possible to create a PDF file, a CSV file, or an RTF file for downloading to a Web browser. The examples below illustrate methods for creating these files.

The following examples contain six separate stored processes which must be run separately. Only one file can be downloaded at a time in a user request.

NOTE: SAS® Web Report Studio does not support the approach that is described in this SAS Note.

/* Example 1: Create a PDF file for downloading */

*ProcessBody;

data _null_; rc = stpsrv_header('Content-type','application/pdf'); rc = stpsrv_header('Content-disposition','attachment; filename=temp.pdf'); run;

ods listing close;

ods PDF body=_webout ;

proc print data=sashelp.class; run;

ODS PDF CLOSE;

/* Example 2: Create a CSV file for downloading */

*ProcessBody;

data _null_; rc = stpsrv_header('Content-type','application/vnd.ms-excel'); rc = stpsrv_header('Content-disposition','attachment; filename=temp.csv'); run;

ods listing close;

ods CSV body=_webout ;

proc print data=sashelp.class; run;

ODS CSV CLOSE;

/* Example 3: Create an RTF file for downloading */

*ProcessBody;

data _null_; rc = stpsrv_header('Content-type','application/vnd.ms-excel'); rc = stpsrv_header('Content-disposition','attachment; filename=temp.rtf'); run;

ods listing close;

ods RTF body=_webout ;

proc print data=sashelp.class; run;

ods rtf close;

/* Example 4: Create a PDF file for downloading using */ /* %STPBEGIN and %STPEND */

*ProcessBody;

data _null_; rc = stpsrv_header('Content-type','application/pdf'); rc = stpsrv_header('Content-disposition','attachment; filename=temp.pdf'); run;

%let _odsdest=pdf;

%stpbegin;

proc print data=sashelp.class; run;

%stpend;

/* Example 5: Create a CSV file for downloading using */ /* %STPBEGIN and %STPEND */

*ProcessBody;

data _null_; rc = stpsrv_header('Content-type','application/vnd.ms-excel'); rc = stpsrv_header('Content-disposition','attachment; filename=temp.csv'); run;

%let _odsdest=csv;

%stpbegin;

proc print data=sashelp.class; run;

%stpend;

/* Example 6: Create a HTML file for downloading to Excel. */ /* Using %STPBEGIN and %STPEND */

*ProcessBody;

data _null_; rc = stpsrv_header('Content-type','application/vnd.ms-excel'); rc = stpsrv_header('Content-disposition','attachment; filename=report.xls'); run;

%stpbegin;

proc print data=sashelp.class; run;

%stpend;