SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ChrisNZ
Tourmaline | Level 20

When running this:

ods excel file='%temp%\reports.xlsx' style=seaside options(flow="tables");
data T ;
  format X $256.;
  X='Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt, explicabo.';
proc print;
run;
ods excel close;

I get this:

ChrisNZ_1-1627446510780.png

I tried using the flow option (which I don't need) to no avail.

Option absolute_column_width doesn't seem to be effective for this either.

Any way to avoid the line break?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ
Hi:
The LINESIZE option would not be having an impact on the ODS EXCEL output. PAGESIZE and LINESIZE are listing only options. I don't observe the same issue when I run a test using SAS 9.4M7, so my recommendation is that the original poster should open a track with Tech Support.
Cynthia

View solution in original post

17 REPLIES 17
andreas_lds
Jade | Level 19

Using m5 the text seems to be misplaced, too:

missplaced_text.png

 

The problem gets worse, when using Report Writing Interface and merged cells, so there seems to be a problem in ods excel.

Spoiler
ods excel file= '%temp%\rwi.xlsx' options (flow= 'tables' embedded_titles='yes');

data _null_;
   set sashelp.class end=jobDone;

   if _n_ = 1 then do;
      declare odsout rwi();
      rwi.table_start();
      rwi.head_start();
      rwi.row_start();
      rwi.format_cell(data: 'Long text, but not to long to fit above the header', column_span: 5);
      rwi.row_end();
      rwi.row_start();
      rwi.format_cell(data: 'Name');
      rwi.format_cell(data: 'Age');
      rwi.format_cell(data: 'Sex');
      rwi.format_cell(data: 'Weight');
      rwi.format_cell(data: 'Height');
      rwi.row_end();
      rwi.head_end();
      rwi.body_start();
   end;

   rwi.row_start();
   rwi.format_cell(data: Name);
   rwi.format_cell(data: Age);
   rwi.format_cell(data: Sex);
   rwi.format_cell(data: Weight);
   rwi.format_cell(data: Height);
   rwi.row_end();

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

ods excel close;

blank_line.png

Ksharp
Super User

Try this style:

 

ods excel file='c:\temp\report.xlsx' style=seaside ;
data T ;
  format X $256.;
  X='Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt, explicabo.';
proc report data=t nowd;
columns x;
define x/style={ tagattr='wrap:no'};
run;
ods excel close;

Ksharp_0-1627476466007.png

 

johnsville
Obsidian | Level 7

I have had this same problem for years.  Adding the tag attribute wraptext=no did not solve the issue, although I now use that by default in every ODS/Excel report I generate.  Buried in discussions here years ago the only solution that effectively fixed it involved processing each row beforehand, then explicitly setting the cell length to be the maximum length encountered when you kick off ODS.  The short story is that ODS/Excel seems to compute a total row length on its own, using assumptions about a display window size, and then wraps text in cells for rows that are longer than the row length it somehow arrives at.. 

 

IF there is something easier that since then seems to solve the issue, I never caught wind of it.  So I am waiting to be educated !

Tom
Super User Tom
Super User

What version of SAS are you using?  The FLOW="TABLES" option was added in 9.4M4.

https://communities.sas.com/t5/ODS-and-Base-Reporting/Lines-Wrapping-in-ODS-Excel/td-p/154925

johnsville
Obsidian | Level 7
9.4 (TS1M4)
Tom
Super User Tom
Super User

Your code works for me, SAS did not insert any HARD line breaks into the field.

image.png

Now if I make the column narrower then Excel will wrap the text. 

image.png

Unless I tell Excel not to "Wrap Text" for that cell/column.

image.png

Are you asking how to remove that Excel Wrap Text option from the cell?

I think you might need to ask SAS support.

 

ChrisNZ
Tourmaline | Level 20

It's not about text wrap, that's why I included the formula bar in my screenshot.

It seems like nothing changes the behaviour.

So flow=  is not in M2 supported apparently, 

absolute_column_width =   enlarges the cell but does not remove the line break.

tagattr='wrap:no'   also has no effect; It probably isn't supported in M2 either.

I'll blame my old 9.4M2 version then. We should upgrade to M7 in the next quarter. Or the next. I might have moved on by then...

Thank you all for your suggestions. Unsure how to chose a solution as I couldn't obtain a result, most likely due to my out-of-date SAS version rather than a non-working answer.

 

 

 

andreas_lds
Jade | Level 19

This could be a display-bug in excel, the screenshots posted earlier were created by m5, for the following m7 has been used:

Without expanding the input field in the formular bar, the text seems cut after "ipsa":

not_expanded_formular.png

But after clicking on the yellow marked arrow, is seems as if a blank line follows the text:

expanded_formular.png

mkeintz
PROC Star

Could the ancient option LINESIZE somehow be influencing PROC PRINT before contents gets passed to the ODS EXCEL facility?

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
ChrisNZ
Tourmaline | Level 20

I can't test now, but I'd be astounded as ODS normally ignores this option.

Ksharp
Super User

Or calling @Cynthia_sas  . She might have some idea.

Cynthia_sas
SAS Super FREQ
Hi:
The LINESIZE option would not be having an impact on the ODS EXCEL output. PAGESIZE and LINESIZE are listing only options. I don't observe the same issue when I run a test using SAS 9.4M7, so my recommendation is that the original poster should open a track with Tech Support.
Cynthia
ChrisNZ
Tourmaline | Level 20

I bother the Tech Support guys often enough with actual defects or issues. The behaviour here clearly seems linked to my out-of-date version (still borken in M5 according to @andreas_lds , fixed in M7 according to @Cynthia_sas, and @Tom an @Ksharp must have been on a recent version too). Thank you all! 

Ksharp
Super User
I am using SAS University Edition ,it should be M6 .

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 17 replies
  • 7590 views
  • 9 likes
  • 8 in conversation