Export xlsx - error NUL ascii caracter

Reply
Occasional Contributor
Posts: 5

Export xlsx - error NUL ascii caracter

Hi,

 

When i export a SAS data table to xlsx and i open the document i have the error "file is corrupted". The problem is that in the txt file data is imported to the SAS table exists the illegal caracter NUL.

How can i remove this ascii caracter - ^@ - NUL when i import to SAS?

 

Regards

Trusted Advisor
Posts: 1,114

Re: Export xlsx - error NUL ascii caracter

Hi @PHRTE,

I would remove the NUL characters from all affected character variables or replace all occurrences of NUL by regular blanks if the NULs have been misused as blanks.

 

Example:

data have;
length a $5;
a=cats('A', '00'x, 'B', '00'x, 'C');
run;


/* Either remove NUL ... */

data want;
set have;
a=compress(a, '00'x);
run;


/* ... or replace NUL */

data want;
set have;
a=translate(a, ' ', '00'x);
run;

Depending on how you "imported" the .txt file it might also be possible to modify the import step in such a way that the NUL characters don't get into the SAS dataset.

 

Esteemed Advisor
Esteemed Advisor
Posts: 7,207

Re: Export xlsx - error NUL ascii caracter

I would go back to the source and ask them to fix the issue.  It may be null values today, or other issues the next day.  I assume you have a data transfer specification in place detailing the structure and content of the data file?  

Ask a Question
Discussion stats
  • 2 replies
  • 198 views
  • 0 likes
  • 3 in conversation