BookmarkSubscribeRSS Feed
yash82
Calcite | Level 5

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 ?????

1 REPLY 1
Cynthia_sas
SAS Super FREQ

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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 698 views
  • 0 likes
  • 2 in conversation