05-10-2017 12:00 PM
I have a DATA table that needs exporting to Excel but it seems to have Return characters etc within it and distorts the export.
This is the "univeral" script that we use in SQL & need to find something similar to run in BASE SAS 9.4 to remove the characters from the data before exporting it.
WHERE (QUESTION_TEXT LIKE '%'+CHAR(10)+'%')
OR (QUESTION_TEXT LIKE '%'+CHAR(13)+'%')
Can someone help please.
05-10-2017 12:20 PM
If you want to remove CR and LF from strings in SAS then use the COMPRESS() function.
data want ; set have; QUESTION_TEXT = compress(QUESTION_TEXT,'0D0A'x); run;
If you want to replace them with single characters you can use the TRANSLATE() function. For example to replace them with spaces you could use.
data want ; set have; QUESTION_TEXT = translate(QUESTION_TEXT,' ','0D0A'x); run;