sorting

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

sorting

albert_sun
Hi,

i have a variables with combinations of A,B,C,D and E. As ABCDE and ADBCE are the same, and how do I make ADBCE to ABCDE in syntax for example?

 
Reply | Threaded
Open this post in threaded view
|

Re: sorting

Ruben Geert van den Berg
Dear Albert,

Please try the syntax below.

data list free/word(a5).
begin data
abc
cba
dbace
ecabd
abcde
end data.

string sorted(a5).
do repeat letter = 'a','b','c','d','e'.
if index(word,letter) > 1 sorted = concat(sorted,letter).
end repeat.
exe.

HTH,

Ruben
Reply | Threaded
Open this post in threaded view
|

Re: sorting

albert_sun
Thanks, Ruben:

I changed 'if index(word,letter) > 1 sorted = concat(sorted,letter)." to "if index(word,letter) >= 1 sorted = concat(sorted,letter). " to make it work as what I want.

Thanks.


On Wed, Sep 18, 2013 at 3:11 PM, Ruben Geert van den Berg [via SPSSX Discussion] <[hidden email]> wrote:
Dear Albert,

Please try the syntax below.

data list free/word(a5).
begin data
abc
cba
dbace
ecabd
abcde
end data.

string sorted(a5).
do repeat letter = 'a','b','c','d','e'.
if index(word,letter) > 1 sorted = concat(sorted,letter).
end repeat.
exe.

HTH,

Ruben


If you reply to this email, your message will be added to the discussion below:
http://spssx-discussion.1045642.n5.nabble.com/sorting-tp5722082p5722083.html
To unsubscribe from sorting, click here.
NAML