How to remove line feed charecters from string variables

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to remove line feed charecters from string variables

Frank Furter
I have an SPSS data set imported from some 3rd party format. The data set includes string variables, and some of the string entries obviously include line feed characters. In text based reports these line feeds unfortunately corrupt the output.

I would like to remove these line feeds from the entered strings using syntax, but I haven't found a way to do this yet. I was thinking of using the REPLACE string function - but how can I specify the line feed character (ASCII 013) in the search string?

Any ideas are appreciated!

Andreas
Reply | Threaded
Open this post in threaded view
|

Re: How to remove line feed characters from string variables

Jon K Peck
We should have this in an FAQ somewhere.  This code replaces CR, LF, and TAB characters with a blank.

compute strvar = replace(strvar, string(10, pib1),' ').
compute strvar = replace(strvar, string(13, pib1),' ').
compute strvar = replace(strvar, string(09, pib1),' ').


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621




From:        Andreas Voelp <[hidden email]>
To:        [hidden email],
Date:        07/09/2013 10:15 AM
Subject:        [SPSSX-L] How to remove line feed charecters from string variables
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




I have an SPSS data set imported from some 3rd party format. The data set
includes string variables, and some of the string entries obviously include
line feed characters. In text based reports these line feeds unfortunately
corrupt the output.

I would like to remove these line feeds from the entered strings using
syntax, but I haven't found a way to do this yet. I was thinking of using
the REPLACE string function - but how can I specify the line feed character
(ASCII 013) in the search string?

Any ideas are appreciated!

Andreas



--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/How-to-remove-line-feed-charecters-from-string-variables-tp5721075.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD


Reply | Threaded
Open this post in threaded view
|

Re: How to remove line feed characters from string variables

Bruce Weaver
Administrator
I've just suggested it to the folks who maintain the SPSS FAQ at UCLA (http://www.ats.ucla.edu/stat/spss/faq/).


Jon K Peck wrote
We should have this in an FAQ somewhere.  This code replaces CR, LF, and
TAB characters with a blank.

compute strvar = replace(strvar, string(10, pib1),' ').
compute strvar = replace(strvar, string(13, pib1),' ').
compute strvar = replace(strvar, string(09, pib1),' ').


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621




From:   Andreas Voelp <[hidden email]>
To:     [hidden email],
Date:   07/09/2013 10:15 AM
Subject:        [SPSSX-L] How to remove line feed charecters from string
variables
Sent by:        "SPSSX(r) Discussion" <[hidden email]>



I have an SPSS data set imported from some 3rd party format. The data set
includes string variables, and some of the string entries obviously
include
line feed characters. In text based reports these line feeds unfortunately
corrupt the output.

I would like to remove these line feeds from the entered strings using
syntax, but I haven't found a way to do this yet. I was thinking of using
the REPLACE string function - but how can I specify the line feed
character
(ASCII 013) in the search string?

Any ideas are appreciated!

Andreas



--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/How-to-remove-line-feed-charecters-from-string-variables-tp5721075.html

Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: How to remove line feed characters from string variables

Frank Furter
In reply to this post by Jon K Peck
Thanks very much - this is exactly what I have been looking for :)

Andreas