Removing Unwanted Characters from a Long String Variable

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

Removing Unwanted Characters from a Long String Variable

Adrianhamouda
Hi everyone. I need help with a large dataset 2,000+ people. The variable I'm
trying to clean up is called 'LanguageFluency'. An example of an observation
in this data set for this variable is 'English (Native/functionally
native)|Spanish/Spanish Creole (Basic)'

What I am trying to do is remove all the characters such as (,/,) so that
all that remains are the letters. This is so I can categorize these
observations into larger groups for analysis.

What I have for code so far is

GET
FILE =  'C:\Users\adrianha\Desktop\CleanedDataMiss.sav'.
LOOP.
COMPUTE removechar = CHAR.INDEX(LanguageFluency,'-|/.\',1) .
IF removechar > 0
X=CONCAT(SUBSTR(LanguageFluency,1,removechar-1),SUBSTR(LanguageFluency,removechar+1)).
END LOOP IF removechar=0.
EXECUTE.

I keep getting an error that there is an invalid combination of datatypes. I
created the numeric variable 'removechar' and 'LanguageFluency' is the
strings of answers submitted on this dataset.

Thanks for any help that can be offered.



--
Sent from: http://spssx-discussion.1045642.n5.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: Removing Unwanted Characters from a Long String Variable

Rick Oliver
I don't think your COMPUTE statement is going to do what you think it's going to do.

How about this:

do repeat x="-", "\", "|", "/".
compute languagefluency=replace(languagefluency, x, "").
end repeat.

On Thu, Feb 8, 2018 at 2:43 PM, Adrianhamouda <[hidden email]> wrote:
Hi everyone. I need help with a large dataset 2,000+ people. The variable I'm
trying to clean up is called 'LanguageFluency'. An example of an observation
in this data set for this variable is 'English (Native/functionally
native)|Spanish/Spanish Creole (Basic)'

What I am trying to do is remove all the characters such as (,/,) so that
all that remains are the letters. This is so I can categorize these
observations into larger groups for analysis.

What I have for code so far is

GET
FILE =  'C:\Users\adrianha\Desktop\CleanedDataMiss.sav'.
LOOP.
COMPUTE removechar = CHAR.INDEX(LanguageFluency,'-|/.\',1) .
IF removechar > 0
X=CONCAT(SUBSTR(LanguageFluency,1,removechar-1),SUBSTR(LanguageFluency,removechar+1)).
END LOOP IF removechar=0.
EXECUTE.

I keep getting an error that there is an invalid combination of datatypes. I
created the numeric variable 'removechar' and 'LanguageFluency' is the
strings of answers submitted on this dataset.

Thanks for any help that can be offered.



--
Sent from: http://spssx-discussion.1045642.n5.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

===================== 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: Removing Unwanted Characters from a Long String Variable

David Marso
Administrator
The source of the error is that X  has not been declared as a STRING.
REPLACE is more concise and efficient.
Probably preferred to not overwrite the original variable until verified.
STRING X (A50).
COMPUTE X=languagefluency.

DO REPEAT ....
COMPUTE .... What Rick said...using X.


Rick Oliver wrote

> I don't think your COMPUTE statement is going to do what you think it's
> going to do.
>
> How about this:
>
> do repeat x="-", "\", "|", "/".
> compute languagefluency=replace(languagefluency, x, "").
> end repeat.
>
> On Thu, Feb 8, 2018 at 2:43 PM, Adrianhamouda &lt;

> adrian.hamouda@

> &gt;
> wrote:
>
>> Hi everyone. I need help with a large dataset 2,000+ people. The variable
>> I'm
>> trying to clean up is called 'LanguageFluency'. An example of an
>> observation
>> in this data set for this variable is 'English (Native/functionally
>> native)|Spanish/Spanish Creole (Basic)'
>>
>> What I am trying to do is remove all the characters such as (,/,) so that
>> all that remains are the letters. This is so I can categorize these
>> observations into larger groups for analysis.
>>
>> What I have for code so far is
>>
>> GET
>> FILE =  'C:\Users\adrianha\Desktop\CleanedDataMiss.sav'.
>> LOOP.
>> COMPUTE removechar = CHAR.INDEX(LanguageFluency,'-|/.\',1) .
>> IF removechar > 0
>> X=CONCAT(SUBSTR(LanguageFluency,1,removechar-1),SUBSTR(LanguageFluency,
>> removechar+1)).
>> END LOOP IF removechar=0.
>> EXECUTE.
>>
>> I keep getting an error that there is an invalid combination of
>> datatypes.
>> I
>> created the numeric variable 'removechar' and 'LanguageFluency' is the
>> strings of answers submitted on this dataset.
>>
>> Thanks for any help that can be offered.
>>
>>
>>
>> --
>> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>>

> LISTSERV@.UGA

>  (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
>>
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
Sent from: http://spssx-discussion.1045642.n5.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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: ODD FINDING:Removing Unwanted Characters from a Long String Variable

David Marso
Administrator
This post was updated on .
I thought I would throw in a third method but it didn't work.
Using identical logic in a fourth method did work.  
Any ideas on why this is the case?
Something very ODD going on with method Three.
----------------------------------
NEW FILE.
DATASET CLOSE ALL.
OUTPUT CLOSE ALL.
DATA LIST LIST /LanguageFluency (A100).
BEGIN DATA
xyz-iaa|se/rt
ff/whej.jj\wj
fgh/rjj|jr.jw
aff-sge/jj|ek
END DATA.

COMMENT : Variation on Original .
STRING LanguageFluency_CPY1 (A100).
COMPUTE LanguageFluency_CPY1=LanguageFluency.
SET MXLOOPS=100.
LOOP.
COMPUTE #removechar = CHAR.INDEX(LanguageFluency_CPY1,'-|/.\',1) .
IF #removechar GT 0
 
LanguageFluency_CPY1=CONCAT(SUBSTR(LanguageFluency_CPY1,1,#removechar-1),SUBSTR(LanguageFluency_CPY1,#removechar+1)).
END LOOP IF #removechar=0.
EXECUTE.

COMMENT : Variation on Rick's .
STRING LanguageFluency_CPY2 (A100).
COMPUTE LanguageFluency_CPY2=LanguageFluency.
DO REPEAT x="-","|","/",".","\".
COMPUTE LanguageFluency_CPY2=REPLACE(LanguageFluency_CPY2, x, "").
END REPEAT.


COMMENT : Another way which I think should work but fails.
STRING LanguageFluency_CPY3 (A100).
COMPUTE LanguageFluency_CPY3=LanguageFluency.
LOOP #x=1 TO LENGTH('-|/.\').
COMPUTE
LanguageFluency_CPY3=REPLACE(LanguageFluency_CPY3,CHAR.SUBSTR('-|/.\',#x,#x+1)
, "").
END LOOP.

COMMENT : Another way 'identical' to version 3 which works.
STRING LanguageFluency_CPY4 (A100).
COMPUTE LanguageFluency_CPY4=LanguageFluency.
STRING # (A1).
LOOP #x=1 TO LENGTH('-|/.\').
COMPUTE #=CHAR.SUBSTR('-|/.\',#x,#x+1).
COMPUTE LanguageFluency_CPY4=REPLACE(LanguageFluency_CPY4,# , "").
END LOOP.
LIST.




-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@LISTSERV.UGA.EDU (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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: ODD FINDING:Removing Unwanted Characters from a Long String Variable

Maguin, Eugene
Hey David,
I'm curious about this line
COMPUTE LanguageFluency_CPY3=REPLACE(LanguageFluency_CPY3,*CHAR.SUBSTR('-|/.\',#x,#x+1)*, "").
And what this piece *CHAR.SUBSTR('-|/.\',#x,#x+1)* does. I get part of it: you want to pass the value of your loop index to the function, which means that the function gets reevaluated each time through the loop. I'm surprised that would ever work but the thing I learned from you, Bruce, Jon, Rick and others is that my thinking about what's possible is far too limited. Anyway, what is the '*' before and after supposed to do?

Gene Maguin



-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Marso
Sent: Friday, February 9, 2018 5:38 AM
To: [hidden email]
Subject: Re: ODD FINDING:Removing Unwanted Characters from a Long String Variable

I thought I would throw in a third method but it didn't work.
Using identical logic in a fourth method did work.  
Any ideas on why this is the case?
Something very ODD going on with method Three.
----------------------------------
NEW FILE.
DATASET CLOSE ALL.
OUTPUT CLOSE ALL.
DATA LIST LIST /LanguageFluency (A100).
BEGIN DATA
xyz-iaa|se/rt
ff/whej.jj\wj
fgh/rjj|jr.jw
aff-sge/jj|ek
END DATA.

COMMENT : Variation on Original .
*STRING LanguageFluency_CPY1 (A100).*
COMPUTE LanguageFluency_CPY1=LanguageFluency.
SET MXLOOPS=100.
LOOP.
COMPUTE #removechar = CHAR.INDEX(LanguageFluency_CPY1,'-|/.\',1) .
IF #removechar GT 0
 
LanguageFluency_CPY1=CONCAT(SUBSTR(LanguageFluency_CPY1,1,#removechar-1),SUBSTR(LanguageFluency_CPY1,#removechar+1)).
END LOOP IF #removechar=0.
EXECUTE.

COMMENT : Variation on Rick's .
STRING LanguageFluency_CPY2 (A100).
COMPUTE LanguageFluency_CPY2=LanguageFluency.
DO REPEAT x="-","|","/",".","\".
COMPUTE LanguageFluency_CPY2=REPLACE(LanguageFluency_CPY2, x, "").
END REPEAT.


COMMENT : Another way which I think should work but fails.
STRING LanguageFluency_CPY3 (A100).
COMPUTE LanguageFluency_CPY3=LanguageFluency.
LOOP #x=1 TO LENGTH('-|/.\').
COMPUTE
LanguageFluency_CPY3=REPLACE(LanguageFluency_CPY3,*CHAR.SUBSTR('-|/.\',#x,#x+1)*
, "").
END LOOP.

COMMENT : Another way 'identical' to version 3 which works.
STRING LanguageFluency_CPY4 (A100).
COMPUTE LanguageFluency_CPY4=LanguageFluency.
STRING # (A1).
LOOP #x=1 TO LENGTH('-|/.\').
COMPUTE #=CHAR.SUBSTR('-|/.\',#x,#x+1).
COMPUTE LanguageFluency_CPY4=REPLACE(LanguageFluency_CPY4,# , "").
END LOOP.
LIST.




-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
Sent from: http://spssx-discussion.1045642.n5.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

=====================
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: ODD FINDING:Removing Unwanted Characters from a Long String Variable

MLIves
David (et al.),

This example David include does work and is exactly what I was planning to suggest.
The beauty of it is that you can expand/contract the values of x as needed.
Is there still a question?

DATA LIST LIST /LanguageFluency (A100).
BEGIN DATA
xyz-iaa|se/rt
ff/whej.jj\wj
fgh/rjj|jr.jw
aff-sge/jj|ek
END DATA

COMMENT : Variation on Rick's .
STRING LanguageFluency_CPY2 (A100).
COMPUTE LanguageFluency_CPY2=LanguageFluency.
DO REPEAT x="-","|","/",".","\".
COMPUTE LanguageFluency_CPY2=REPLACE(LanguageFluency_CPY2, x, "").
END REPEAT.

--------------
Melissa Ives

________________________________________
From: SPSSX(r) Discussion <[hidden email]> on behalf of Maguin, Eugene <[hidden email]>
Sent: Friday, February 9, 2018 9:09 AM
To: [hidden email]
Subject: Re: [SPSSX-L] ODD FINDING:Removing Unwanted Characters from a Long String Variable

Hey David,
I'm curious about this line
COMPUTE LanguageFluency_CPY3=REPLACE(LanguageFluency_CPY3,*CHAR.SUBSTR('-|/.\',#x,#x+1)*, "").
And what this piece *CHAR.SUBSTR('-|/.\',#x,#x+1)* does. I get part of it: you want to pass the value of your loop index to the function, which means that the function gets reevaluated each time through the loop. I'm surprised that would ever work but the thing I learned from you, Bruce, Jon, Rick and others is that my thinking about what's possible is far too limited. Anyway, what is the '*' before and after supposed to do?

Gene Maguin



-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Marso
Sent: Friday, February 9, 2018 5:38 AM
To: [hidden email]
Subject: Re: ODD FINDING:Removing Unwanted Characters from a Long String Variable

I thought I would throw in a third method but it didn't work.
Using identical logic in a fourth method did work.
Any ideas on why this is the case?
Something very ODD going on with method Three.
----------------------------------
NEW FILE.
DATASET CLOSE ALL.
OUTPUT CLOSE ALL.
DATA LIST LIST /LanguageFluency (A100).
BEGIN DATA
xyz-iaa|se/rt
ff/whej.jj\wj
fgh/rjj|jr.jw
aff-sge/jj|ek
END DATA.

COMMENT : Variation on Original .
*STRING LanguageFluency_CPY1 (A100).*
COMPUTE LanguageFluency_CPY1=LanguageFluency.
SET MXLOOPS=100.
LOOP.
COMPUTE #removechar = CHAR.INDEX(LanguageFluency_CPY1,'-|/.\',1) .
IF #removechar GT 0

LanguageFluency_CPY1=CONCAT(SUBSTR(LanguageFluency_CPY1,1,#removechar-1),SUBSTR(LanguageFluency_CPY1,#removechar+1)).
END LOOP IF #removechar=0.
EXECUTE.

COMMENT : Variation on Rick's .
STRING LanguageFluency_CPY2 (A100).
COMPUTE LanguageFluency_CPY2=LanguageFluency.
DO REPEAT x="-","|","/",".","\".
COMPUTE LanguageFluency_CPY2=REPLACE(LanguageFluency_CPY2, x, "").
END REPEAT.


COMMENT : Another way which I think should work but fails.
STRING LanguageFluency_CPY3 (A100).
COMPUTE LanguageFluency_CPY3=LanguageFluency.
LOOP #x=1 TO LENGTH('-|/.\').
COMPUTE
LanguageFluency_CPY3=REPLACE(LanguageFluency_CPY3,*CHAR.SUBSTR('-|/.\',#x,#x+1)*
, "").
END LOOP.

COMMENT : Another way 'identical' to version 3 which works.
STRING LanguageFluency_CPY4 (A100).
COMPUTE LanguageFluency_CPY4=LanguageFluency.
STRING # (A1).
LOOP #x=1 TO LENGTH('-|/.\').
COMPUTE #=CHAR.SUBSTR('-|/.\',#x,#x+1).
COMPUTE LanguageFluency_CPY4=REPLACE(LanguageFluency_CPY4,# , "").
END LOOP.
LIST.




-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
Sent from: http://spssx-discussion.1045642.n5.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

=====================
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

________________________________

This correspondence contains proprietary information some or all of which may be legally privileged; it is for the intended recipient only. If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this correspondence and completely dispose of the correspondence immediately. Please notify the sender if you have received this email in error. NOTE: Messages to or from the State of Connecticut domain may be subject to the Freedom of Information statutes and regulations.

=====================
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: ODD FINDING:Removing Unwanted Characters from a Long String Variable

David Marso
Administrator
In reply to this post by Maguin, Eugene
I bold formatted sections of my code for emphasis but unfortunately Nabble
flanks the bolds with *.
So the code in question:
COMPUTE
LanguageFluency_CPY3=REPLACE(LanguageFluency_CPY3,*CHAR.SUBSTR('-|/.\',#x,#x+1)*,
"").

Is really :
COMPUTE
LanguageFluency_CPY3=REPLACE(LanguageFluency_CPY3,CHAR.SUBSTR('-|/.\',#x,#x+1),
"").

LanguageFluency_CPY3, Prior to transformation:
xyz-iaa|se/rt
ff/whej.jj\wj
fgh/rjj|jr.jw
aff-sge/jj|ek

Unpacked,
First time through loop #x=1. Replacement character = '-'.
LanguageFluency_CPY3=
xyziaa|se/rt
ff/whej.jj\wj
fgh/rjj|jr.jw
affsge/jj|ek

Second time through loop #x= 2. Replacement character = '|'.
LanguageFluency_CPY3=
xyziaase/rt
ff/whej.jj\wj
fgh/rjjjr.jw
affsge/jjek

Third time through loop #x= 3.  Replacement character = '/'.
LanguageFluency_CPY3=
xyziaasert
ffwhej.jj\wj
fghrjjjr.jw
affsgejjek

Fourth time through loop #x= 4.  Replacement character = '.'.
LanguageFluency_CPY3=
xyziaasert
ffwhejjj\wj
fghrjjjrjw
affsgejjek

Fifth time through loop #x= 5.  Replacement character = '\'.
LanguageFluency_CPY3=
xyziaasert
ffwhejjjwj
fghrjjjrjw
affsgejjek

BUT the damned thing doesn't work in place but if I parse it into a string
as in version four it works as expected.
Maybe Jon or someone else has insights into WTF is going on here.




Maguin, Eugene wrote

> Hey David,
> I'm curious about this line
> COMPUTE
> LanguageFluency_CPY3=REPLACE(LanguageFluency_CPY3,*CHAR.SUBSTR('-|/.\',#x,#x+1)*,
> "").
> And what this piece *CHAR.SUBSTR('-|/.\',#x,#x+1)* does. I get part of it:
> you want to pass the value of your loop index to the function, which means
> that the function gets reevaluated each time through the loop. I'm
> surprised that would ever work but the thing I learned from you, Bruce,
> Jon, Rick and others is that my thinking about what's possible is far too
> limited. Anyway, what is the '*' before and after supposed to do?
>
> Gene Maguin
>
>
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:

> SPSSX-L@.UGA

> ] On Behalf Of David Marso
> Sent: Friday, February 9, 2018 5:38 AM
> To:

> SPSSX-L@.UGA

> Subject: Re: ODD FINDING:Removing Unwanted Characters from a Long String
> Variable
>
> I thought I would throw in a third method but it didn't work.
> Using identical logic in a fourth method did work.  
> Any ideas on why this is the case?
> Something very ODD going on with method Three.
> ----------------------------------
> NEW FILE.
> DATASET CLOSE ALL.
> OUTPUT CLOSE ALL.
> DATA LIST LIST /LanguageFluency (A100).
> BEGIN DATA
> xyz-iaa|se/rt
> ff/whej.jj\wj
> fgh/rjj|jr.jw
> aff-sge/jj|ek
> END DATA.
>
> COMMENT : Variation on Original .
> *STRING LanguageFluency_CPY1 (A100).*
> COMPUTE LanguageFluency_CPY1=LanguageFluency.
> SET MXLOOPS=100.
> LOOP.
> COMPUTE #removechar = CHAR.INDEX(LanguageFluency_CPY1,'-|/.\',1) .
> IF #removechar GT 0
>  
> LanguageFluency_CPY1=CONCAT(SUBSTR(LanguageFluency_CPY1,1,#removechar-1),SUBSTR(LanguageFluency_CPY1,#removechar+1)).
> END LOOP IF #removechar=0.
> EXECUTE.
>
> COMMENT : Variation on Rick's .
> STRING LanguageFluency_CPY2 (A100).
> COMPUTE LanguageFluency_CPY2=LanguageFluency.
> DO REPEAT x="-","|","/",".","\".
> COMPUTE LanguageFluency_CPY2=REPLACE(LanguageFluency_CPY2, x, "").
> END REPEAT.
>
>
> COMMENT : Another way which I think should work but fails.
> STRING LanguageFluency_CPY3 (A100).
> COMPUTE LanguageFluency_CPY3=LanguageFluency.
> LOOP #x=1 TO LENGTH('-|/.\').
> COMPUTE
> LanguageFluency_CPY3=REPLACE(LanguageFluency_CPY3,*CHAR.SUBSTR('-|/.\',#x,#x+1)*
> , "").
> END LOOP.
>
> COMMENT : Another way 'identical' to version 3 which works.
> STRING LanguageFluency_CPY4 (A100).
> COMPUTE LanguageFluency_CPY4=LanguageFluency.
> STRING # (A1).
> LOOP #x=1 TO LENGTH('-|/.\').
> COMPUTE #=CHAR.SUBSTR('-|/.\',#x,#x+1).
> COMPUTE LanguageFluency_CPY4=REPLACE(LanguageFluency_CPY4,# , "").
> END LOOP.
> LIST.
>
>
>
>
> -----
> Please reply to the list and not to my personal email.
> Those desiring my consulting or training services please feel free to
> email me.
> ---
> "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos
> ne forte conculcent eas pedibus suis."
> Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in
> abyssum?"
> --
> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
Sent from: http://spssx-discussion.1045642.n5.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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: ODD FINDING:Removing Unwanted Characters from a Long String Variable

Art Kendall
In reply to this post by David Marso
did you intend to comment out
*STRING LanguageFluency_CPY1 (A100).*
?



-----
Art Kendall
Social Research Consultants
--
Sent from: http://spssx-discussion.1045642.n5.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
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: ODD FINDING:Removing Unwanted Characters from a Long String Variable

David Marso
Administrator
NO.  It ws an attempt to BOLD for emphasis.  Basically the only thing that OP
was missing from otherwise functional code.


Art Kendall wrote

> did you intend to comment out
> *STRING LanguageFluency_CPY1 (A100).*
> ?
>
>
>
> -----
> Art Kendall
> Social Research Consultants
> --
> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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


Art Kendall wrote

> did you intend to comment out
> *STRING LanguageFluency_CPY1 (A100).*
> ?
>
>
>
> -----
> Art Kendall
> Social Research Consultants
> --
> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
Sent from: http://spssx-discussion.1045642.n5.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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: ODD FINDING:Removing Unwanted Characters from a Long String Variable

Jon Peck
In reply to this post by David Marso
After removing the "*" characters, I don't understand why your length parameter isn't always 1, i.e.,
COMPUTE
LanguageFluency_CPY3=REPLACE(LanguageFluency_CPY3,  CHAR.SUBSTR('-|/.\', #x, 1), "").

The third parameter of CHAR.SUBSTR is not the ending position.  It is the length. of the substring.
I think example 4 works because the STRING # (A1) truncates the extra bytes from CHAR.SUBSTR.



On Fri, Feb 9, 2018 at 8:08 AM, David Marso <[hidden email]> wrote:
I bold formatted sections of my code for emphasis but unfortunately Nabble
flanks the bolds with *.
So the code in question:
COMPUTE
LanguageFluency_CPY3=REPLACE(LanguageFluency_CPY3,*CHAR.SUBSTR('-|/.\',#x,#x+1)*,
"").

Is really :
COMPUTE
LanguageFluency_CPY3=REPLACE(LanguageFluency_CPY3,CHAR.SUBSTR('-|/.\',#x,#x+1),
"").

LanguageFluency_CPY3, Prior to transformation:
xyz-iaa|se/rt
ff/whej.jj\wj
fgh/rjj|jr.jw
aff-sge/jj|ek

Unpacked,
First time through loop #x=1. Replacement character = '-'.
LanguageFluency_CPY3=
xyziaa|se/rt
ff/whej.jj\wj
fgh/rjj|jr.jw
affsge/jj|ek

Second time through loop #x= 2. Replacement character = '|'.
LanguageFluency_CPY3=
xyziaase/rt
ff/whej.jj\wj
fgh/rjjjr.jw
affsge/jjek

Third time through loop #x= 3.  Replacement character = '/'.
LanguageFluency_CPY3=
xyziaasert
ffwhej.jj\wj
fghrjjjr.jw
affsgejjek

Fourth time through loop #x= 4.  Replacement character = '.'.
LanguageFluency_CPY3=
xyziaasert
ffwhejjj\wj
fghrjjjrjw
affsgejjek

Fifth time through loop #x= 5.  Replacement character = '\'.
LanguageFluency_CPY3=
xyziaasert
ffwhejjjwj
fghrjjjrjw
affsgejjek

BUT the damned thing doesn't work in place but if I parse it into a string
as in version four it works as expected.
Maybe Jon or someone else has insights into WTF is going on here.




Maguin, Eugene wrote
> Hey David,
> I'm curious about this line
> COMPUTE
> LanguageFluency_CPY3=REPLACE(LanguageFluency_CPY3,*CHAR.SUBSTR('-|/.\',#x,#x+1)*,
> "").
> And what this piece *CHAR.SUBSTR('-|/.\',#x,#x+1)* does. I get part of it:
> you want to pass the value of your loop index to the function, which means
> that the function gets reevaluated each time through the loop. I'm
> surprised that would ever work but the thing I learned from you, Bruce,
> Jon, Rick and others is that my thinking about what's possible is far too
> limited. Anyway, what is the '*' before and after supposed to do?
>
> Gene Maguin
>
>
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:

> SPSSX-L@.UGA

> ] On Behalf Of David Marso
> Sent: Friday, February 9, 2018 5:38 AM
> To:

> SPSSX-L@.UGA

> Subject: Re: ODD FINDING:Removing Unwanted Characters from a Long String
> Variable
>
> I thought I would throw in a third method but it didn't work.
> Using identical logic in a fourth method did work.
> Any ideas on why this is the case?
> Something very ODD going on with method Three.
> ----------------------------------
> NEW FILE.
> DATASET CLOSE ALL.
> OUTPUT CLOSE ALL.
> DATA LIST LIST /LanguageFluency (A100).
> BEGIN DATA
> xyz-iaa|se/rt
> ff/whej.jj\wj
> fgh/rjj|jr.jw
> aff-sge/jj|ek
> END DATA.
>
> COMMENT : Variation on Original .
> *STRING LanguageFluency_CPY1 (A100).*
> COMPUTE LanguageFluency_CPY1=LanguageFluency.
> SET MXLOOPS=100.
> LOOP.
> COMPUTE #removechar = CHAR.INDEX(LanguageFluency_CPY1,'-|/.\',1) .
> IF #removechar GT 0
>
> LanguageFluency_CPY1=CONCAT(SUBSTR(LanguageFluency_CPY1,1,#removechar-1),SUBSTR(LanguageFluency_CPY1,#removechar+1)).
> END LOOP IF #removechar=0.
> EXECUTE.
>
> COMMENT : Variation on Rick's .
> STRING LanguageFluency_CPY2 (A100).
> COMPUTE LanguageFluency_CPY2=LanguageFluency.
> DO REPEAT x="-","|","/",".","\".
> COMPUTE LanguageFluency_CPY2=REPLACE(LanguageFluency_CPY2, x, "").
> END REPEAT.
>
>
> COMMENT : Another way which I think should work but fails.
> STRING LanguageFluency_CPY3 (A100).
> COMPUTE LanguageFluency_CPY3=LanguageFluency.
> LOOP #x=1 TO LENGTH('-|/.\').
> COMPUTE
> LanguageFluency_CPY3=REPLACE(LanguageFluency_CPY3,*CHAR.SUBSTR('-|/.\',#x,#x+1)*
> , "").
> END LOOP.
>
> COMMENT : Another way 'identical' to version 3 which works.
> STRING LanguageFluency_CPY4 (A100).
> COMPUTE LanguageFluency_CPY4=LanguageFluency.
> STRING # (A1).
> LOOP #x=1 TO LENGTH('-|/.\').
> COMPUTE #=CHAR.SUBSTR('-|/.\',#x,#x+1).
> COMPUTE LanguageFluency_CPY4=REPLACE(LanguageFluency_CPY4,# , "").
> END LOOP.
> LIST.
>
>
>
>
> -----
> Please reply to the list and not to my personal email.
> Those desiring my consulting or training services please feel free to
> email me.
> ---
> "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos
> ne forte conculcent eas pedibus suis."
> Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in
> abyssum?"
> --
> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
Sent from: http://spssx-discussion.1045642.n5.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



--
Jon K Peck
[hidden email]

===================== 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: ODD FINDING:Removing Unwanted Characters from a Long String Variable

David Marso
Administrator
In reply to this post by MLIves
It does work.  The OP code works as well except the STRING declaration was
omitted  resulting in the error. My fourth example also works.  The third
one should work as well but fails.  Have any idea why?
It is functionally equivalent to version FOUR.

This also works and is quite concise as far as required calling syntax.

Friday morning would not be complete without a recursive macro  :-]

SYNTAX:
!RecReplace  OriginalVariable > [NewPredeclaredVariable]  SPACE separated
List of ReplacedValues.

DEFINE !RecReplace (!POS !CHAREND(">") /!POS !ENCLOSE("[","]") /!POS !CMDEND  
).
!IF (!3 !NE "" ) !THEN
!RecReplace !CONCAT("REPLACE(",!1,",",!QUOTE(!HEAD(!3 )),",'')"  ) > [!2]
!TAIL(!3)
!ELSE
COMPUTE !2 = !1.
!IFEND
!ENDDEFINE.

SET MPRINT ON.
STRING LanguageFluency_CPY5(A100).
!RecReplace LanguageFluency> [LanguageFluency_CPY5] . - | / \  .

EXPANSION:

COMPUTE LanguageFluency_CPY5 =
 
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(LanguageFluency,'.',''),'-',''),'|',''),'/',''),'
\','').



Ives, Melissa L wrote

> David (et al.),
>
> This example David include does work and is exactly what I was planning to
> suggest.
> The beauty of it is that you can expand/contract the values of x as
> needed.
> Is there still a question?
>
> DATA LIST LIST /LanguageFluency (A100).
> BEGIN DATA
> xyz-iaa|se/rt
> ff/whej.jj\wj
> fgh/rjj|jr.jw
> aff-sge/jj|ek
> END DATA
>
> COMMENT : Variation on Rick's .
> STRING LanguageFluency_CPY2 (A100).
> COMPUTE LanguageFluency_CPY2=LanguageFluency.
> DO REPEAT x="-","|","/",".","\".
> COMPUTE LanguageFluency_CPY2=REPLACE(LanguageFluency_CPY2, x, "").
> END REPEAT.
>
> --------------
> Melissa Ives
>
> ________________________________________
> From: SPSSX(r) Discussion &lt;

> SPSSX-L@.UGA

> &gt; on behalf of Maguin, Eugene &lt;

> emaguin@

> &gt;
> Sent: Friday, February 9, 2018 9:09 AM
> To:

> SPSSX-L@.UGA

> Subject: Re: [SPSSX-L] ODD FINDING:Removing Unwanted Characters from a
> Long String Variable
>
> Hey David,
> I'm curious about this line
> COMPUTE
> LanguageFluency_CPY3=REPLACE(LanguageFluency_CPY3,*CHAR.SUBSTR('-|/.\',#x,#x+1)*,
> "").
> And what this piece *CHAR.SUBSTR('-|/.\',#x,#x+1)* does. I get part of it:
> you want to pass the value of your loop index to the function, which means
> that the function gets reevaluated each time through the loop. I'm
> surprised that would ever work but the thing I learned from you, Bruce,
> Jon, Rick and others is that my thinking about what's possible is far too
> limited. Anyway, what is the '*' before and after supposed to do?
>
> Gene Maguin
>
>
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:

> SPSSX-L@.UGA

> ] On Behalf Of David Marso
> Sent: Friday, February 9, 2018 5:38 AM
> To:

> SPSSX-L@.UGA

> Subject: Re: ODD FINDING:Removing Unwanted Characters from a Long String
> Variable
>
> I thought I would throw in a third method but it didn't work.
> Using identical logic in a fourth method did work.
> Any ideas on why this is the case?
> Something very ODD going on with method Three.
> ----------------------------------
> NEW FILE.
> DATASET CLOSE ALL.
> OUTPUT CLOSE ALL.
> DATA LIST LIST /LanguageFluency (A100).
> BEGIN DATA
> xyz-iaa|se/rt
> ff/whej.jj\wj
> fgh/rjj|jr.jw
> aff-sge/jj|ek
> END DATA.
>
> COMMENT : Variation on Original .
> *STRING LanguageFluency_CPY1 (A100).*
> COMPUTE LanguageFluency_CPY1=LanguageFluency.
> SET MXLOOPS=100.
> LOOP.
> COMPUTE #removechar = CHAR.INDEX(LanguageFluency_CPY1,'-|/.\',1) .
> IF #removechar GT 0
>
> LanguageFluency_CPY1=CONCAT(SUBSTR(LanguageFluency_CPY1,1,#removechar-1),SUBSTR(LanguageFluency_CPY1,#removechar+1)).
> END LOOP IF #removechar=0.
> EXECUTE.
>
> COMMENT : Variation on Rick's .
> STRING LanguageFluency_CPY2 (A100).
> COMPUTE LanguageFluency_CPY2=LanguageFluency.
> DO REPEAT x="-","|","/",".","\".
> COMPUTE LanguageFluency_CPY2=REPLACE(LanguageFluency_CPY2, x, "").
> END REPEAT.
>
>
> COMMENT : Another way which I think should work but fails.
> STRING LanguageFluency_CPY3 (A100).
> COMPUTE LanguageFluency_CPY3=LanguageFluency.
> LOOP #x=1 TO LENGTH('-|/.\').
> COMPUTE
> LanguageFluency_CPY3=REPLACE(LanguageFluency_CPY3,*CHAR.SUBSTR('-|/.\',#x,#x+1)*
> , "").
> END LOOP.
>
> COMMENT : Another way 'identical' to version 3 which works.
> STRING LanguageFluency_CPY4 (A100).
> COMPUTE LanguageFluency_CPY4=LanguageFluency.
> STRING # (A1).
> LOOP #x=1 TO LENGTH('-|/.\').
> COMPUTE #=CHAR.SUBSTR('-|/.\',#x,#x+1).
> COMPUTE LanguageFluency_CPY4=REPLACE(LanguageFluency_CPY4,# , "").
> END LOOP.
> LIST.
>
>
>
>
> -----
> Please reply to the list and not to my personal email.
> Those desiring my consulting or training services please feel free to
> email me.
> ---
> "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos
> ne forte conculcent eas pedibus suis."
> Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in
> abyssum?"
> --
> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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
>
> ________________________________
>
> This correspondence contains proprietary information some or all of which
> may be legally privileged; it is for the intended recipient only. If you
> are not the intended recipient you must not use, disclose, distribute,
> copy, print, or rely on this correspondence and completely dispose of the
> correspondence immediately. Please notify the sender if you have received
> this email in error. NOTE: Messages to or from the State of Connecticut
> domain may be subject to the Freedom of Information statutes and
> regulations.
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
Sent from: http://spssx-discussion.1045642.n5.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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: ODD FINDING:Removing Unwanted Characters from a Long String Variable

Jon Peck
In reply to this post by Jon Peck
As long as we are accumulating methods for the replacement, here's a one liner using the SPSSINC TRANS extension command.  It uses a regular expression that matches any of the undesired characters and replaces with nothing into a new A100 variable, LanguageFluencyCPY.

spssinc trans result=LanguageFluencyCPY type=100 /formula "re.sub(r'[-|/\.]', '', LanguageFluency)".

On Fri, Feb 9, 2018 at 10:51 AM, David Marso <[hidden email]> wrote:
My bad.  I was not paying attention ;-]

On Fri, Feb 9, 2018 at 11:51 AM, Jon Peck <[hidden email]> wrote:
Not, because the declared length of # is one byte, so the CHAR.SUBSTR result gets truncated.

On Fri, Feb 9, 2018 at 9:36 AM David Marso <[hidden email]> wrote:
Brain fart on my end.
I always thought it was the ending position in the string to extract.
OTOH with your fix version three works.
BUT: Consider this?
Why if the third argument is the desired length of the substring why does
this print single characters?
ODD????? First time through #x+1 = 2,etc, should it not print -|, then -|/
etc?
Seems that something is amiss in Docs-land.

DATA LIST FREE /X.
BEGIN DATA
1
END DATA.
STRING # (A1).
LOOP #x=1 TO LENGTH('-|/.\').
COMPUTE #=CHAR.SUBSTR('-|/.\',#x,#x+1).
PRINT / #.
END LOOP.
EXECUTE.
-
|
/
.
\


Jon Peck wrote
> After removing the "*" characters, I don't understand why your length
> parameter isn't always 1, i.e.,
> COMPUTE
> LanguageFluency_CPY3=REPLACE(LanguageFluency_CPY3,  CHAR.SUBSTR('-|/.\',
> #x, 1), "").
>
> The third parameter of CHAR.SUBSTR is not the ending position.  It is the
> length. of the substring.
> I think example 4 works because the STRING # (A1) truncates the extra
> bytes
> from CHAR.SUBSTR.
>
>
>
> On Fri, Feb 9, 2018 at 8:08 AM, David Marso &lt;

> david.marso@

> &gt; wrote:
>
>> I bold formatted sections of my code for emphasis but unfortunately
>> Nabble
>> flanks the bolds with *.
>> So the code in question:
>> COMPUTE
>> LanguageFluency_CPY3=REPLACE(LanguageFluency_CPY3,*CHAR.
>> SUBSTR('-|/.\',#x,#x+1)*,
>> "").
>>
>> Is really :
>> COMPUTE
>> LanguageFluency_CPY3=REPLACE(LanguageFluency_CPY3,CHAR.

>> SUBSTR('-|/.\',#x,#x+1),
>> "").
>>
>> LanguageFluency_CPY3, Prior to transformation:
>> xyz-iaa|se/rt
>> ff/whej.jj\wj
>> fgh/rjj|jr.jw
>> aff-sge/jj|ek
>>
>> Unpacked,
>> First time through loop #x=1. Replacement character = '-'.
>> LanguageFluency_CPY3=
>> xyziaa|se/rt
>> ff/whej.jj\wj
>> fgh/rjj|jr.jw
>> affsge/jj|ek
>>
>> Second time through loop #x= 2. Replacement character = '|'.
>> LanguageFluency_CPY3=
>> xyziaase/rt
>> ff/whej.jj\wj
>> fgh/rjjjr.jw
>> affsge/jjek
>>
>> Third time through loop #x= 3.  Replacement character = '/'.
>> LanguageFluency_CPY3=
>> xyziaasert
>> ffwhej.jj\wj
>> fghrjjjr.jw
>> affsgejjek
>>
>> Fourth time through loop #x= 4.  Replacement character = '.'.
>> LanguageFluency_CPY3=
>> xyziaasert
>> ffwhejjj\wj
>> fghrjjjrjw
>> affsgejjek
>>
>> Fifth time through loop #x= 5.  Replacement character = '\'.
>> LanguageFluency_CPY3=
>> xyziaasert
>> ffwhejjjwj
>> fghrjjjrjw
>> affsgejjek
>>
>> BUT the damned thing doesn't work in place but if I parse it into a
>> string
>> as in version four it works as expected.
>> Maybe Jon or someone else has insights into WTF is going on here.
>>
>>
>>
>>
>> Maguin, Eugene wrote
>> > Hey David,
>> > I'm curious about this line
>> > COMPUTE
>> > LanguageFluency_CPY3=REPLACE(LanguageFluency_CPY3,*CHAR.

>> SUBSTR('-|/.\',#x,#x+1)*,
>> > "").
>> > And what this piece *CHAR.SUBSTR('-|/.\',#x,#x+1)* does. I get part of
>> it:
>> > you want to pass the value of your loop index to the function, which
>> means
>> > that the function gets reevaluated each time through the loop. I'm
>> > surprised that would ever work but the thing I learned from you, Bruce,
>> > Jon, Rick and others is that my thinking about what's possible is far
>> too
>> > limited. Anyway, what is the '*' before and after supposed to do?
>> >
>> > Gene Maguin
>> >
>> >
>> >
>> > -----Original Message-----
>> > From: SPSSX(r) Discussion [mailto:
>>
>> > SPSSX-L@.UGA
>>
>> > ] On Behalf Of David Marso
>> > Sent: Friday, February 9, 2018 5:38 AM
>> > To:
>>
>> > SPSSX-L@.UGA
>>
>> > Subject: Re: ODD FINDING:Removing Unwanted Characters from a Long
>> String
>> > Variable
>> >
>> > I thought I would throw in a third method but it didn't work.
>> > Using identical logic in a fourth method did work.
>> > Any ideas on why this is the case?
>> > Something very ODD going on with method Three.
>> > ----------------------------------
>> > NEW FILE.
>> > DATASET CLOSE ALL.
>> > OUTPUT CLOSE ALL.
>> > DATA LIST LIST /LanguageFluency (A100).
>> > BEGIN DATA
>> > xyz-iaa|se/rt
>> > ff/whej.jj\wj
>> > fgh/rjj|jr.jw
>> > aff-sge/jj|ek
>> > END DATA.
>> >
>> > COMMENT : Variation on Original .
>> > *STRING LanguageFluency_CPY1 (A100).*
>> > COMPUTE LanguageFluency_CPY1=LanguageFluency.
>> > SET MXLOOPS=100.
>> > LOOP.
>> > COMPUTE #removechar = CHAR.INDEX(LanguageFluency_CPY1,'-|/.\',1) .
>> > IF #removechar GT 0
>> >
>> > LanguageFluency_CPY1=CONCAT(SUBSTR(LanguageFluency_CPY1,1,
>> #removechar-1),SUBSTR(LanguageFluency_CPY1,#removechar+1)).
>> > END LOOP IF #removechar=0.
>> > EXECUTE.
>> >
>> > COMMENT : Variation on Rick's .
>> > STRING LanguageFluency_CPY2 (A100).
>> > COMPUTE LanguageFluency_CPY2=LanguageFluency.
>> > DO REPEAT x="-","|","/",".","\".
>> > COMPUTE LanguageFluency_CPY2=REPLACE(LanguageFluency_CPY2, x, "").
>> > END REPEAT.
>> >
>> >
>> > COMMENT : Another way which I think should work but fails.
>> > STRING LanguageFluency_CPY3 (A100).
>> > COMPUTE LanguageFluency_CPY3=LanguageFluency.
>> > LOOP #x=1 TO LENGTH('-|/.\').
>> > COMPUTE
>> > LanguageFluency_CPY3=REPLACE(LanguageFluency_CPY3,*CHAR.
>> SUBSTR('-|/.\',#x,#x+1)*
>> > , "").
>> > END LOOP.
>> >
>> > COMMENT : Another way 'identical' to version 3 which works.
>> > STRING LanguageFluency_CPY4 (A100).
>> > COMPUTE LanguageFluency_CPY4=LanguageFluency.
>> > STRING # (A1).
>> > LOOP #x=1 TO LENGTH('-|/.\').
>> > COMPUTE #=CHAR.SUBSTR('-|/.\',#x,#x+1).
>> > COMPUTE LanguageFluency_CPY4=REPLACE(LanguageFluency_CPY4,# , "").
>> > END LOOP.
>> > LIST.
>> >
>> >
>> >
>> >
>> > -----
>> > Please reply to the list and not to my personal email.
>> > Those desiring my consulting or training services please feel free to
>> > email me.
>> > ---
>> > "Nolite dare sanctum canibus neque mittatis margaritas vestras ante
>> porcos
>> > ne forte conculcent eas pedibus suis."
>> > Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff
>> in
>> > abyssum?"
>> > --
>> > Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>> >
>> > =====================
>> > To manage your subscription to SPSSX-L, send a message to
>>
>> > LISTSERV@.UGA
>>
>> >  (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
>> >
>> > =====================
>> > To manage your subscription to SPSSX-L, send a message to
>>
>> > LISTSERV@.UGA
>>
>> >  (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
>>
>>
>>
>>
>>
>> -----
>> Please reply to the list and not to my personal email.
>> Those desiring my consulting or training services please feel free to
>> email me.
>> ---
>> "Nolite dare sanctum canibus neque mittatis margaritas vestras ante
>> porcos
>> ne forte conculcent eas pedibus suis."
>> Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff
>> in
>> abyssum?"
>> --
>> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>>

> LISTSERV@.UGA

>  (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
>>
>
>
>
> --
> Jon K Peck

> jkpeck@


>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
Sent from: http://spssx-discussion.1045642.n5.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
--
Jon K Peck
[hidden email]





--
Jon K Peck
[hidden email]

===================== 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: ODD FINDING:Removing Unwanted Characters from a Long String Variable

MLIves
In reply to this post by David Marso
CHAR.SUBSTR('-|/.\',#x,#x+1)

I don't think you need the '+1 above since each iteration would still only look at 1 character and the #x increases via the loop.
CHAR.SUBSTR. CHAR.SUBSTR(strexpr,pos[,length])

Try it with just:
CHAR.SUBSTR('-|/.\',#x, 1)

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Marso
Sent: Friday, February 09, 2018 11:10 AM
To: [hidden email]
Subject: Re: [SPSSX-L] ODD FINDING:Removing Unwanted Characters from a Long String Variable

It does work.  The OP code works as well except the STRING declaration was omitted  resulting in the error. My fourth example also works.  The third one should work as well but fails.  Have any idea why?
It is functionally equivalent to version FOUR.

This also works and is quite concise as far as required calling syntax.

Friday morning would not be complete without a recursive macro  :-]

SYNTAX:
!RecReplace  OriginalVariable > [NewPredeclaredVariable]  SPACE separated List of ReplacedValues.

DEFINE !RecReplace (!POS !CHAREND(">") /!POS !ENCLOSE("[","]") /!POS !CMDEND ).
!IF (!3 !NE "" ) !THEN
!RecReplace !CONCAT("REPLACE(",!1,",",!QUOTE(!HEAD(!3 )),",'')"  ) > [!2]
!TAIL(!3)
!ELSE
COMPUTE !2 = !1.
!IFEND
!ENDDEFINE.

SET MPRINT ON.
STRING LanguageFluency_CPY5(A100).
!RecReplace LanguageFluency> [LanguageFluency_CPY5] . - | / \  .

EXPANSION:

COMPUTE LanguageFluency_CPY5 =

REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(LanguageFluency,'.',''),'-',''),'|',''),'/',''),'
\','').



Ives, Melissa L wrote

> David (et al.),
>
> This example David include does work and is exactly what I was
> planning to suggest.
> The beauty of it is that you can expand/contract the values of x as
> needed.
> Is there still a question?
>
> DATA LIST LIST /LanguageFluency (A100).
> BEGIN DATA
> xyz-iaa|se/rt
> ff/whej.jj\wj
> fgh/rjj|jr.jw
> aff-sge/jj|ek
> END DATA
>
> COMMENT : Variation on Rick's .
> STRING LanguageFluency_CPY2 (A100).
> COMPUTE LanguageFluency_CPY2=LanguageFluency.
> DO REPEAT x="-","|","/",".","\".
> COMPUTE LanguageFluency_CPY2=REPLACE(LanguageFluency_CPY2, x, "").
> END REPEAT.
>
> --------------
> Melissa Ives
>
> ________________________________________
> From: SPSSX(r) Discussion &lt;

> SPSSX-L@.UGA

> &gt; on behalf of Maguin, Eugene &lt;

> emaguin@

> &gt;
> Sent: Friday, February 9, 2018 9:09 AM
> To:

> SPSSX-L@.UGA

> Subject: Re: [SPSSX-L] ODD FINDING:Removing Unwanted Characters from a
> Long String Variable
>
> Hey David,
> I'm curious about this line
> COMPUTE
> LanguageFluency_CPY3=REPLACE(LanguageFluency_CPY3,*CHAR.SUBSTR('-|/.\'
> ,#x,#x+1)*,
> "").
> And what this piece *CHAR.SUBSTR('-|/.\',#x,#x+1)* does. I get part of it:
> you want to pass the value of your loop index to the function, which
> means that the function gets reevaluated each time through the loop.
> I'm surprised that would ever work but the thing I learned from you,
> Bruce, Jon, Rick and others is that my thinking about what's possible
> is far too limited. Anyway, what is the '*' before and after supposed to do?
>
> Gene Maguin
>
>
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:

> SPSSX-L@.UGA

> ] On Behalf Of David Marso
> Sent: Friday, February 9, 2018 5:38 AM
> To:

> SPSSX-L@.UGA

> Subject: Re: ODD FINDING:Removing Unwanted Characters from a Long
> String Variable
>
> I thought I would throw in a third method but it didn't work.
> Using identical logic in a fourth method did work.
> Any ideas on why this is the case?
> Something very ODD going on with method Three.
> ----------------------------------
> NEW FILE.
> DATASET CLOSE ALL.
> OUTPUT CLOSE ALL.
> DATA LIST LIST /LanguageFluency (A100).
> BEGIN DATA
> xyz-iaa|se/rt
> ff/whej.jj\wj
> fgh/rjj|jr.jw
> aff-sge/jj|ek
> END DATA.
>
> COMMENT : Variation on Original .
> *STRING LanguageFluency_CPY1 (A100).*
> COMPUTE LanguageFluency_CPY1=LanguageFluency.
> SET MXLOOPS=100.
> LOOP.
> COMPUTE #removechar = CHAR.INDEX(LanguageFluency_CPY1,'-|/.\',1) .
> IF #removechar GT 0
>
> LanguageFluency_CPY1=CONCAT(SUBSTR(LanguageFluency_CPY1,1,#removechar-1),SUBSTR(LanguageFluency_CPY1,#removechar+1)).
> END LOOP IF #removechar=0.
> EXECUTE.
>
> COMMENT : Variation on Rick's .
> STRING LanguageFluency_CPY2 (A100).
> COMPUTE LanguageFluency_CPY2=LanguageFluency.
> DO REPEAT x="-","|","/",".","\".
> COMPUTE LanguageFluency_CPY2=REPLACE(LanguageFluency_CPY2, x, "").
> END REPEAT.
>
>
> COMMENT : Another way which I think should work but fails.
> STRING LanguageFluency_CPY3 (A100).
> COMPUTE LanguageFluency_CPY3=LanguageFluency.
> LOOP #x=1 TO LENGTH('-|/.\').
> COMPUTE
> LanguageFluency_CPY3=REPLACE(LanguageFluency_CPY3,*CHAR.SUBSTR('-|/.\'
> ,#x,#x+1)*
> , "").
> END LOOP.
>
> COMMENT : Another way 'identical' to version 3 which works.
> STRING LanguageFluency_CPY4 (A100).
> COMPUTE LanguageFluency_CPY4=LanguageFluency.
> STRING # (A1).
> LOOP #x=1 TO LENGTH('-|/.\').
> COMPUTE #=CHAR.SUBSTR('-|/.\',#x,#x+1).
> COMPUTE LanguageFluency_CPY4=REPLACE(LanguageFluency_CPY4,# , "").
> END LOOP.
> LIST.
>
>
>
>
> -----
> Please reply to the list and not to my personal email.
> Those desiring my consulting or training services please feel free to
> email me.
> ---
> "Nolite dare sanctum canibus neque mittatis margaritas vestras ante
> porcos ne forte conculcent eas pedibus suis."
> Cum es damnatorum possederunt porcos iens ut salire off sanguinum
> cliff in abyssum?"
> --
> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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
>
> ________________________________
>
> This correspondence contains proprietary information some or all of
> which may be legally privileged; it is for the intended recipient
> only. If you are not the intended recipient you must not use,
> disclose, distribute, copy, print, or rely on this correspondence and
> completely dispose of the correspondence immediately. Please notify
> the sender if you have received this email in error. NOTE: Messages to
> or from the State of Connecticut domain may be subject to the Freedom
> of Information statutes and regulations.
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
Sent from: http://spssx-discussion.1045642.n5.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

________________________________

This correspondence contains proprietary information some or all of which may be legally privileged; it is for the intended recipient only. If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this correspondence and completely dispose of the correspondence immediately. Please notify the sender if you have received this email in error. NOTE: Messages to or from the State of Connecticut domain may be subject to the Freedom of Information statutes and regulations.

=====================
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: ODD FINDING:Removing Unwanted Characters from a Long String Variable

David Marso
Administrator
Yes, it should just be CHAR.SUBSTR('-|/.\',#x, 1).

On Tue, Feb 13, 2018 at 9:52 AM, Ives, Melissa L <[hidden email]> wrote:
CHAR.SUBSTR('-|/.\',#x,#x+1)

I don't think you need the '+1 above since each iteration would still only look at 1 character and the #x increases via the loop.
CHAR.SUBSTR. CHAR.SUBSTR(strexpr,pos[,length])

Try it with just:
CHAR.SUBSTR('-|/.\',#x, 1)

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Marso
Sent: Friday, February 09, 2018 11:10 AM
To: [hidden email]
Subject: Re: [SPSSX-L] ODD FINDING:Removing Unwanted Characters from a Long String Variable

It does work.  The OP code works as well except the STRING declaration was omitted  resulting in the error. My fourth example also works.  The third one should work as well but fails.  Have any idea why?
It is functionally equivalent to version FOUR.

This also works and is quite concise as far as required calling syntax.

Friday morning would not be complete without a recursive macro  :-]

SYNTAX:
!RecReplace  OriginalVariable > [NewPredeclaredVariable]  SPACE separated List of ReplacedValues.

DEFINE !RecReplace (!POS !CHAREND(">") /!POS !ENCLOSE("[","]") /!POS !CMDEND ).
!IF (!3 !NE "" ) !THEN
!RecReplace !CONCAT("REPLACE(",!1,",",!QUOTE(!HEAD(!3 )),",'')"  ) > [!2]
!TAIL(!3)
!ELSE
COMPUTE !2 = !1.
!IFEND
!ENDDEFINE.

SET MPRINT ON.
STRING LanguageFluency_CPY5(A100).
!RecReplace LanguageFluency> [LanguageFluency_CPY5] . - | / \  .

EXPANSION:

COMPUTE LanguageFluency_CPY5 =

REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(LanguageFluency,'.',''),'-',''),'|',''),'/',''),'
\','').



Ives, Melissa L wrote
> David (et al.),
>
> This example David include does work and is exactly what I was
> planning to suggest.
> The beauty of it is that you can expand/contract the values of x as
> needed.
> Is there still a question?
>
> DATA LIST LIST /LanguageFluency (A100).
> BEGIN DATA
> xyz-iaa|se/rt
> ff/whej.jj\wj
> fgh/rjj|jr.jw
> aff-sge/jj|ek
> END DATA
>
> COMMENT : Variation on Rick's .
> STRING LanguageFluency_CPY2 (A100).
> COMPUTE LanguageFluency_CPY2=LanguageFluency.
> DO REPEAT x="-","|","/",".","\".
> COMPUTE LanguageFluency_CPY2=REPLACE(LanguageFluency_CPY2, x, "").
> END REPEAT.
>
> --------------
> Melissa Ives
>
> ________________________________________
> From: SPSSX(r) Discussion &lt;

> SPSSX-L@.UGA

> &gt; on behalf of Maguin, Eugene &lt;

> emaguin@

> &gt;
> Sent: Friday, February 9, 2018 9:09 AM
> To:

> SPSSX-L@.UGA

> Subject: Re: [SPSSX-L] ODD FINDING:Removing Unwanted Characters from a
> Long String Variable
>
> Hey David,
> I'm curious about this line
> COMPUTE
> LanguageFluency_CPY3=REPLACE(LanguageFluency_CPY3,*CHAR.SUBSTR('-|/.\'
> ,#x,#x+1)*,
> "").
> And what this piece *CHAR.SUBSTR('-|/.\',#x,#x+1)* does. I get part of it:
> you want to pass the value of your loop index to the function, which
> means that the function gets reevaluated each time through the loop.
> I'm surprised that would ever work but the thing I learned from you,
> Bruce, Jon, Rick and others is that my thinking about what's possible
> is far too limited. Anyway, what is the '*' before and after supposed to do?
>
> Gene Maguin
>
>
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:

> SPSSX-L@.UGA

> ] On Behalf Of David Marso
> Sent: Friday, February 9, 2018 5:38 AM
> To:

> SPSSX-L@.UGA

> Subject: Re: ODD FINDING:Removing Unwanted Characters from a Long
> String Variable
>
> I thought I would throw in a third method but it didn't work.
> Using identical logic in a fourth method did work.
> Any ideas on why this is the case?
> Something very ODD going on with method Three.
> ----------------------------------
> NEW FILE.
> DATASET CLOSE ALL.
> OUTPUT CLOSE ALL.
> DATA LIST LIST /LanguageFluency (A100).
> BEGIN DATA
> xyz-iaa|se/rt
> ff/whej.jj\wj
> fgh/rjj|jr.jw
> aff-sge/jj|ek
> END DATA.
>
> COMMENT : Variation on Original .
> *STRING LanguageFluency_CPY1 (A100).*
> COMPUTE LanguageFluency_CPY1=LanguageFluency.
> SET MXLOOPS=100.
> LOOP.
> COMPUTE #removechar = CHAR.INDEX(LanguageFluency_CPY1,'-|/.\',1) .
> IF #removechar GT 0
>
> LanguageFluency_CPY1=CONCAT(SUBSTR(LanguageFluency_CPY1,1,#removechar-1),SUBSTR(LanguageFluency_CPY1,#removechar+1)).
> END LOOP IF #removechar=0.
> EXECUTE.
>
> COMMENT : Variation on Rick's .
> STRING LanguageFluency_CPY2 (A100).
> COMPUTE LanguageFluency_CPY2=LanguageFluency.
> DO REPEAT x="-","|","/",".","\".
> COMPUTE LanguageFluency_CPY2=REPLACE(LanguageFluency_CPY2, x, "").
> END REPEAT.
>
>
> COMMENT : Another way which I think should work but fails.
> STRING LanguageFluency_CPY3 (A100).
> COMPUTE LanguageFluency_CPY3=LanguageFluency.
> LOOP #x=1 TO LENGTH('-|/.\').
> COMPUTE
> LanguageFluency_CPY3=REPLACE(LanguageFluency_CPY3,*CHAR.SUBSTR('-|/.\'
> ,#x,#x+1)*
> , "").
> END LOOP.
>
> COMMENT : Another way 'identical' to version 3 which works.
> STRING LanguageFluency_CPY4 (A100).
> COMPUTE LanguageFluency_CPY4=LanguageFluency.
> STRING # (A1).
> LOOP #x=1 TO LENGTH('-|/.\').
> COMPUTE #=CHAR.SUBSTR('-|/.\',#x,#x+1).
> COMPUTE LanguageFluency_CPY4=REPLACE(LanguageFluency_CPY4,# , "").
> END LOOP.
> LIST.
>
>
>
>
> -----
> Please reply to the list and not to my personal email.
> Those desiring my consulting or training services please feel free to
> email me.
> ---
> "Nolite dare sanctum canibus neque mittatis margaritas vestras ante
> porcos ne forte conculcent eas pedibus suis."
> Cum es damnatorum possederunt porcos iens ut salire off sanguinum
> cliff in abyssum?"
> --
> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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
>
> ________________________________
>
> This correspondence contains proprietary information some or all of
> which may be legally privileged; it is for the intended recipient
> only. If you are not the intended recipient you must not use,
> disclose, distribute, copy, print, or rely on this correspondence and
> completely dispose of the correspondence immediately. Please notify
> the sender if you have received this email in error. NOTE: Messages to
> or from the State of Connecticut domain may be subject to the Freedom
> of Information statutes and regulations.
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (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





-----
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
--
Sent from: http://spssx-discussion.1045642.n5.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

________________________________

This correspondence contains proprietary information some or all of which may be legally privileged; it is for the intended recipient only. If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this correspondence and completely dispose of the correspondence immediately. Please notify the sender if you have received this email in error. NOTE: Messages to or from the State of Connecticut domain may be subject to the Freedom of Information statutes and regulations.


===================== 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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"