How to remove carriage return and linefeed characters within quoted strings.

October 27, 2011
By

This post was kindly contributed by StudySAS Blog - go there to comment and to read the full post.


HANDLING SPECIAL EMBEDDED CHARACTERS

To manage and report data in DBMS that contains very long text fields is not easy. This can be frustrating if the text field has special embedded symbols such as tabs, carriage returns (‘OD’x ), line feeds (‘OA’x) and page breaks. But here is simple SAS code which takes care of those issues.

The normal line end for Windows text files is a  carriage return character or a line feed character so

 The syntax for taking out all carriage return (‘OD’x) and line feed (‘OA’x) characters is comment= Compress(comment,’0D0A’x);

                             or

comment= TRANWRD(comment,’0D0A’x,’’);

If you just want to take out the Carriage Return, use this code:

comment= TRANWRD(comment,’0D’x,”);

You could also try this one too..

Comment=compress(Comment, ,”kw”);*k is for keep, w is for…

[[ This is a content summary only. Visit my website for full links, other content, and more! ]]

This post was kindly contributed by StudySAS Blog - go there to comment and to read the full post.

Tags: , , , ,

Welcome!

SAS-X.com offers news and tutorials about the various SAS® software packages, contributed by bloggers. You are welcome to subscribe to e-mail updates, or add your SAS-blog to the site.

Sponsors







Dear readers, proc-x is looking for sponsors who would be willing to support the site in exchange for banner ads in the right sidebar of the site. If you are interested, please e-mail me at: tal.galili@gmail.com
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration.