BookmarkSubscribeRSS Feed
andreas_lds
Jade | Level 19

I need to create an excel-file with embedded titles and the title needs text aligned on left and right in the same line. This can easily be done with a title-statement (see code below), but as soon as ods excel comes into play, the automatic column-spanning hides parts of the left-aligned title. So i moved the title-text to the data step, with rwi inserting rows before the header of a table works well, except for one thing: the heights of the rows is unnecessary large.

I can't use the option row_heights in the ods-statement, because i need the automatic height-calculation for the data.

PartlyHiddenTitle.PNG

ods excel 
      file= "rwi_title.xlsx"
      options(
         flow= "data"
         sheet_interval= "none"
         embedded_titles= 'yes'
      );


proc sql noprint;
   select Name into :varList separated by ' '
      from sashelp.vcolumn
         where libname = 'SASHELP' and memname = 'CARS'
   ;
quit;


/*title1 justify=left "The most fantastic sashelp.cars" justify=right "%sysfunc(today(), ddmmyyp10.)";*/

data _null_;
   set sashelp.cars end=done;

   if _n_ = 1 then do;
      declare odsout rwi();

      rwi.table_start();
      rwi.head_start();

      rwi.row_start(); /* height seems to be calculated without considering column_span */
      rwi.format_cell(data: 'The most fantastic sashelp.cars', column_span: 10, style_attr: 'color= red');
      rwi.format_cell(data: "%sysfunc(today(), ddmmyyp10.)", column_span: 5, just: 'R', style_attr: 'color= red');
      rwi.row_end();

      rwi.row_start();
      rwi.format_cell(data: 'CARS', column_span: 10, style_attr: 'color= red');
      rwi.format_cell(data: 'CARS', column_span: 5, just: 'R', style_attr: 'color= red');
      rwi.row_end();

      rwi.row_start();
      do i = 1 to countw("&varList");
         rwi.format_cell(data: scan("&varList.", i));
      end;
      rwi.row_end();
      rwi.head_end();
      rwi.body_start();
   end;

   rwi.row_start();
   do i = 1 to countw("&varList");
      rwi.format_cell(data: vvaluex(scan("&varList.", i)));
   end;
   rwi.row_end();

   if done then do;
      rwi.body_end();
      rwi.table_end();
   end;
run;

title;

ods excel close;

Is this is feature in 9.4m5?

2 REPLIES 2
Cynthia_sas
SAS Super FREQ

Hi:

  Removing RWI from the equation, with just a plain title statement, I can use the TITLE_FOOTNOTE_WIDTH= sub-option to specify the number of columns that the title should span. This works for me:

Cynthia_sas_0-1588977854783.png

Of course the LINE statement in PROC REPORT automatically spans the whole table. But the sub-option and the title statement should work no matter what the procedure or step is.

Cynthia

andreas_lds
Jade | Level 19

Thanks for your time, will look try it next week, when i am back in office.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2 replies
  • 1587 views
  • 0 likes
  • 2 in conversation