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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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