The SAS Output Delivery System and reporting techniques

odsout observations getting printed to new page

Reply
Contributor
Posts: 25

odsout observations getting printed to new page

Hi Guys, My PDF output is getting printed to new page for every observation in data _null_  . Please find code below

data _null_;

set temp2 end=eof;

dcl odsout obj();

obj.table_start(name: "acc",overrides:"width=4in" );

obj.row_start(type:"header");

obj.format_cell(text: "Report Title1",column_span: 3 );

obj.row_end();

obj.row_start(type:"header");

obj.format_cell(text:"Age",overrides:"just=left");

obj.format_cell(text:"Sex:",overrides:"just=left");

obj.row_end();

obj.row_start();

obj.format_cell(data:num_of_clm,overrides );

obj.format_cell(data:ag);

obj.format_cell(data:sx);

obj.row_end();

;run;

Now I have 16 observations in my temp dataset and after applying the above code I am getting desired output but there are 16 pages of PDF this is not what I am expecting.

I believe there must be some option for this. I tried using column_span and overrides but its not working...  Has anyone encountered problem on something like this before ?????

SAS Super FREQ
Posts: 8,744

Re: odsout observations getting printed to new page

Hi:

  Do you really want to declare a new object and start a new table for EVERY observation? If you look at some of the code examples in this paper, they use _N_ and FIRST.byvar to control how they are writing/creating the object:

http://support.sas.com/rnd/base/datastep/dsobject/Power_to_show_paper.pdf

  If you continue to have issues with your code, you might consider working with Tech Support on this question.

cynthia

** Added this simple example that uses SASHELP.CLASS which has 19 observations;

options nodate nonumber;

ods pdf file='c:\temp\test_null.pdf';

title 'SAS Report Title';

data _null_;

set sashelp.class end=eof;

** at beginning of data, create the table;

** and write the headers;

if _n_ = 1 then do;

  dcl odsout obj();

  obj.table_start(name: "acc",overrides:"width=4in" );

  ** start the header row that spans the whole table;

  obj.row_start(type:"header");

    obj.format_cell(text: "Table Spanning Header",column_span: 3 );

  obj.row_end();

  ** start the header row for each column;

  obj.row_start(type:"header");

    obj.format_cell(text:"Name",overrides:"just=center");

    obj.format_cell(text:"Age",overrides:"just=center");

    obj.format_cell(text:"Sex",overrides:"just=left");

  obj.row_end();

end;

   

** write a row for every observation;

obj.row_start(type:"data",style:"Data");

  obj.format_cell(data:name,overrides:"color=purple fontweight=bold background=pink" );

  obj.format_cell(data:age,overrides:"just=right");

  obj.format_cell(data:sex);

obj.row_end();

  

** at end of file, write a table footer and then;

** close the table object;

if eof then do;

  obj.row_start(type:"Header");

    obj.format_cell(style:"Header",text: "Table Spanning Footer",column_span: 3 );

  obj.row_end();

  obj.table_end();

end;

run;

       

ods pdf close;

Ask a Question
Discussion stats
  • 1 reply
  • 182 views
  • 0 likes
  • 2 in conversation