Pick a Display, Any Display - The Power of _odsdest in Stored Processes

0

Here is a code snippet I came up with today to save output with various _odsoptions AND allow the users to choose what type of output they need: RTF, PDF, or HTML.
(Note that this will default to PDF if the user doesn't pick anything. Also there is a report parameter of company that the user chooses. This defines not only the report itself but the filename default!)

%global  company _odsdest _odsstyle _odsoptions;
%let _odsstyle=SASWEB;
%macro head;
%put "&&_odsdest.";
%if "&&_odsdest." = "RTF" %then %do;
%let _odsoptions = startpage=NO;
data _null_;
  rc = stpsrv_header('Content-type',"application/&&company..msword;");
  rc = stpsrv_header('Content-disposition',"attachment; filename=&&company..rtf;");
run;
%end;
%IF %length(&_odsdest) = 0 or "&&_odsdest." = "PDF" %THEN %DO ;
%let _odsdest=PDF;
%let _odsoptions = startpage=NO notoc;
%symdel _ODSSTYLESHEET;
data _null_;
  rc = stpsrv_header('Content-type','application/pdf');
  rc = stpsrv_header('Content-disposition',"attachment; filename=&&company..pdf;");
run;
%end;
%mend;
%head;
 
%stpbegin;
            * insert your sas code here
%stpend;
Share

About Author

Angela Hall

Senior Technical Architect

Angela offers tips on using the SAS Business Intelligence solutions. She manages a team of SAS Fraud Framework implementers within the SAS Solutions On-Demand organization. Angela also has co-written two books, 'Building BI using SAS, Content Development Examples' & 'The 50 Keys to Learning SAS Stored Processes'.

Comments are closed.

Back to Top