Wednesday, October 7, 2015

SAS: Remove carriage return from string

I had a problem with a dataset with a single string field, created using datalines, and the line ended with carriage return + line feed ('0a0d'x), but code was copied to Linux where it was run, and Linux ends its lines with line feed only ('0a'x), so the field contained the carriage return.  I needed to strip the carriage return from the field. I added this line within the data step that created the file.

  my_field = TRANWRD(my_field,'0D'x,'');




No comments:

Post a Comment