The SAS Output Delivery System and reporting techniques

ODS EXCEL - Blanks get lost if lines wrap

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 8
Accepted Solution

ODS EXCEL - Blanks get lost if lines wrap

Hi,

 

I would like to export a file via ODS EXCEL and then reimport the new generated Excel file via PROC IMPORT. My problem is that ODS EXCEL wraps lines in the table cells if there is not enough place.This would be no problem but unfortunately the blanks get lost between the last word in the first line and the first word in the second line. So the values of the variables are not the same after PROC IMPORT. Here is a test program:

 

filename mdata "c:\test.xlsx";

ods excel file=mdata;

ods excel options (sheet_label="TEST" sheet_name="TEST");

data test;

test1='ABCD EFGH IJKL MNOP QRST UVW XYZ';

test2='ABCD EFGH IJKL MNOP QRST UVW XYZ';

test3='ABCD EFGH IJKL MNOP QRST UVW XYZ';

test4='ABCD EFGH IJKL MNOP QRST UVW XYZ';

test5='ABCD EFGH IJKL MNOP QRST UVW XYZ';

run;

proc report data=test nowindows;

column test1 test2 test3 test4 test5;

define test1 / display ;

define test2 / display ;

define test3 / display ;

define test4 / display ;

define test5 / display ;

run;

ods excel close;

 

proc import datafile="c:\test.xlsx" out=test dbms=xlsx replace;

sheet="TEST";

run;

 

Has anyone a solution for this or a workaround

 

Thanks

 

Gerd

 


Accepted Solutions
Solution
‎11-11-2016 08:12 AM
Respected Advisor
Posts: 3,799

Re: ODS EXCEL - Blanks get lost if lines wrap

[ Edited ]

It appears thats ODS EXCEL is inserting a LF '0A'X at the point where the text is wrapped.  If you print the TEST variables after import with $HEX64.  you can see what you actually have.

 

You can "adjust" the wrap point by specifying the CELLWIDTH style option.  If you make it big enough there will be NO LFs added.

 

View solution in original post


All Replies
Super User
Posts: 7,832

Re: ODS EXCEL - Blanks get lost if lines wrap

What's the purpose of this crazyness? You have the most powerful statistics/analytics package at hand, and then push your data through the excel dungheap.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 10,041

Re: ODS EXCEL - Blanks get lost if lines wrap

I don't understand your question. I got the same thing between them.

 

 
filename mdata "/folders/myfolders/test.xlsx";
ods excel file=mdata;
ods excel options (sheet_label="TEST" sheet_name="TEST");
data test;
test1='ABCD EFGH IJKL MNOP QRST UVW XYZ';
test2='ABCD EFGH IJKL MNOP QRST UVW XYZ';
test3='ABCD EFGH IJKL MNOP QRST UVW XYZ';
test4='ABCD EFGH IJKL MNOP QRST UVW XYZ';
test5='ABCD EFGH IJKL MNOP QRST UVW XYZ';
run;
proc report data=test nowindows;
run;
ods excel close;
 
proc import datafile="/folders/myfolders/test.xlsx" out=test dbms=xlsx replace;
sheet="TEST";
run;
 

x.png

Occasional Contributor
Posts: 8

Re: ODS EXCEL - Blanks get lost if lines wrap

The value of the variables  in the SAS dataset TEST as result of PROC IMPORT is

'ABCD EFGH IJKL MNOP QRST

UVW XYZ'

without the blank between T and U because of the line feed in the excel cell.

But maybe there is a hidden special character there, because I have copied this from the SAS dataset and the line feed is still there, but not visible in the data ?

 

Best regards,

 

Gerd

Solution
‎11-11-2016 08:12 AM
Respected Advisor
Posts: 3,799

Re: ODS EXCEL - Blanks get lost if lines wrap

[ Edited ]

It appears thats ODS EXCEL is inserting a LF '0A'X at the point where the text is wrapped.  If you print the TEST variables after import with $HEX64.  you can see what you actually have.

 

You can "adjust" the wrap point by specifying the CELLWIDTH style option.  If you make it big enough there will be NO LFs added.

 

Occasional Contributor
Posts: 8

Re: ODS EXCEL - Blanks get lost if lines wrap

Posted in reply to data_null__

Ah ok. That's the problem.

 

Thank you very much !

 

Best regards,

 

Gerd

 

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 660 views
  • 0 likes
  • 4 in conversation