The SAS Output Delivery System and reporting techniques

Displaying ODSOUT object output

Not applicable
Posts: 1

Displaying ODSOUT object output

Dear all,

The following Code is an attempt to use the pre-production ODSOUT object  to display PDF output WITHIN the SAS Stored Process Web App.

I dont want the output to go to a physical file, just be displayed in the Web App Browser. Is it possible to do what I am attempting?

I am currently at SAS9.2 TS2M0. on Windows 64.




options nomlogic mprint;


ods pdf bookmarkgen=NO;

%macro odsoutTest;

data _null_;
  set sashelp.class end=eof;
  if _n_=1 then do;
    dcl odsout obj();
      obj.format_cell(data: 'Name');
      obj.format_cell(data: 'Weight');
      obj.format_cell(data: 'Age');
    obj.format_cell(data: name);
    obj.format_cell(data: weight);
    obj.format_cell(data: age);
  if eof then do;

%mend odsoutTest;





The SAS log has the following:

NOTE: Writing ODS PDF output to DISK destination "C:\SAS\Config\Lev2\SASApp\sasprt.pdf", printer "PDF".
12        +

13        +

14        +%macro odsoutTest;

15        +

16        +data _null_;

17        +  set sashelp.class end=eof;

18        +  if _n_=1 then do;

19        +    dcl odsout obj();

20        +    obj.table_start();

21        +    obj.row_start();

22        +      obj.format_cell(data: 'Name');

23        +      obj.format_cell(data: 'Weight');

24        +      obj.format_cell(data: 'Age');

25        +    obj.row_end();

26        +  end;

27        +  obj.row_start();

28        +    obj.format_cell(data: name);

29        +    obj.format_cell(data: weight);

30        +    obj.format_cell(data: age);

31        +  obj.row_end();

32        +  if eof then do;

33        +    obj.table_end();

34        +  end;

35        +run;

36        +

37        +%mend odsoutTest;

                                                                                          The SAS System

38        +

39        +title;

40        +footnote;

41        +

42        +%stpbegin;

MPRINT(STPBEGIN):   options nonotes;

MPRINT(STPBEGIN):   ods listing close;


43        +

44        +%odsoutTest;

MPRINT(ODSOUTTEST):   data _null_;

MPRINT(ODSOUTTEST):   set sashelp.class end=eof;

MPRINT(ODSOUTTEST):   if _n_=1 then do;

MPRINT(ODSOUTTEST):   dcl odsout obj();

MPRINT(ODSOUTTEST):   obj.table_start();

MPRINT(ODSOUTTEST):   obj.row_start();

MPRINT(ODSOUTTEST):   obj.format_cell(data: 'Name');

MPRINT(ODSOUTTEST):   obj.format_cell(data: 'Weight');

MPRINT(ODSOUTTEST):   obj.format_cell(data: 'Age');

MPRINT(ODSOUTTEST):   obj.row_end();


MPRINT(ODSOUTTEST):   obj.row_start();

MPRINT(ODSOUTTEST):   obj.format_cell(data: name);

MPRINT(ODSOUTTEST):   obj.format_cell(data: weight);

MPRINT(ODSOUTTEST):   obj.format_cell(data: age);

MPRINT(ODSOUTTEST):   obj.row_end();

MPRINT(ODSOUTTEST):   if eof then do;

MPRINT(ODSOUTTEST):   obj.table_end();



WARNING: DATA step interface is preproduction in this release.
NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      user cpu time       0.00 seconds
      system cpu time     0.00 seconds
      Memory                            255950k
                                                                                          The SAS System

      OS Memory                         266844k
      Timestamp            1/11/2011  1:51:19 PM

45        +

46        +%stpend;

MPRINT(STPEND):   options nonotes;

MPRINT(STPEND):   ods _ALL_ close;


47        +

48        +

NOTE: %INCLUDE (level 1) ending.

Posts: 9,370

Displaying ODSOUT object output


  Normally, you do not do use %STPBEGIN in the way you show. Where is your override to &_ODSDEST that changes the destination to PDF??? Or, where is your use of _WEBOUT?? This Tech Support note shows the general method for producing a PDF result from a stored process:

  Without an override to &_ODSDEST or the use of _WEBOUT, as shown, the default of SASReport XML or HTML will be returned to the client application (depending on your client -- would be SASReport XML for Web Report Studio; might be HTML for the Information Delivery Portal). When you say you are returning results to the "Web App browser", I figure you mean the Stored Process Web App (SPWA). I think that even for the SPWA, you need an override to the regular content-type header that is used/needed for streaming results. To set the appropriate content-type header, you use the STPSRV_HEADER function.

You might want to work with Tech Support on this question. It is more probable that your issues are caused by how you invoked the stored process. If you use %STPBEGIN and there is no override to &_ODSDEST, then you are not getting PDF results at all. I am also not sure why you are creating a session, either. Usually, you only need to create a session if your stored process is going to go back to the server to get something (like a dataset or an image or ???), but I don't see that you use the session. And, for PDF output, in particular, images are embedded inside the PDF document at the time the PDF is created, so if you do manage to create PDF output, I'm not sure why you'd need to persist a session on the server.

  An example of persisting a session, with the SPWA, would be an example where 1) the underlying premise is that you are building your own HTML and 2) you start a session and create a SAVE dataset with a list of unique countries. You build the HTML in your program and 3) send it back to the web browser. Then the user makes a choice on the form and 4) you want to have the FORM action tag go back to the same session on the server, so you can access the list of unique countries for some further processing and then 5) you send new results back to the web browser. This type of "request/response" isn't really the type of thing to do with a PDF file of stored process results.


Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation