BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Gerd_64
Fluorite | Level 6

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

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

5 REPLIES 5
Kurt_Bremser
Super User

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.

Ksharp
Super User

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

Gerd_64
Fluorite | Level 6

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

data_null__
Jade | Level 19

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.

 

Gerd_64
Fluorite | Level 6

Ah ok. That's the problem.

 

Thank you very much !

 

Best regards,

 

Gerd

 

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 5 replies
  • 2701 views
  • 0 likes
  • 4 in conversation