Concatenate

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

Concatenate

subscribe SPSSX-l Anonymous-2
Hello All,

I have 3 variables which I recoded.  The three variables are mutually
exclusive and I'm trying to combine the 3 variables into 1.  However, when
I'm trying to concatenate the 3 variables together it only populates the
first variable I created (CE).  Do you know what I could be doing wrong?

Current sample data:

ConEd   FirstT   TRans
CE
CE
         FT
         FT
                  TR
                  TR

Need the data to look like this:

newDATA
CE
CE
FT
FT
TR
TR

Below is what I was working with.


STRING CE (A2).
RECODE newCON_ED (1='CE') INTO CE.
VARIABLE LABELS  CE 'continuing ed'.
EXECUTE.

STRING FT (A2).
RECODE newFIRST_TIME (1='FT') INTO FT.
VARIABLE LABELS  FT 'First-time'.
EXECUTE.

STRING TR (A2).
RECODE newTRANSFER (1='TR') INTO TR.
VARIABLE LABELS  TR 'Transfer'.
EXECUTE.

STRING  newDATA (A6).
IF  (CE = "CE" | FT = "FT" | TR = "TR") newDATA=CONCAT(CE,FT,TR).
VARIABLE LABELS  newDATA 'IF (CE = "CE" | FT = "FT" | TR = "TR")
newDATA=CONCAT(CE,FT,TR) '.
EXECUTE.


Thanks in advance,

Michelle K.

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

Art Kendall
Open a new instance of SPSS.  Copy the syntax below to a syntax file.
Click <run>. Click <all>.

data list list /ConEd (a2)  FirstT (a2)  TRans (a2).
begin data
'CE'
'CE'
'' 'FT'
'' 'FT'
'' '' 'TR'
end data.

string newdata(a2).
compute newdata = max(coned,firstt,trans).
list.

Art Kendall
Social Research Consultants


subscribe SPSSX-l Anonymous wrote:

> Hello All,
>
> I have 3 variables which I recoded.  The three variables are mutually
> exclusive and I'm trying to combine the 3 variables into 1.  However, when
> I'm trying to concatenate the 3 variables together it only populates the
> first variable I created (CE).  Do you know what I could be doing wrong?
>
> Current sample data:
>
> ConEd   FirstT   TRans
> CE
> CE
>          FT
>          FT
>                   TR
>                   TR
>
> Need the data to look like this:
>
> newDATA
> CE
> CE
> FT
> FT
> TR
> TR
>
> Below is what I was working with.
>
>
> STRING CE (A2).
> RECODE newCON_ED (1='CE') INTO CE.
> VARIABLE LABELS  CE 'continuing ed'.
> EXECUTE.
>
> STRING FT (A2).
> RECODE newFIRST_TIME (1='FT') INTO FT.
> VARIABLE LABELS  FT 'First-time'.
> EXECUTE.
>
> STRING TR (A2).
> RECODE newTRANSFER (1='TR') INTO TR.
> VARIABLE LABELS  TR 'Transfer'.
> EXECUTE.
>
> STRING  newDATA (A6).
> IF  (CE = "CE" | FT = "FT" | TR = "TR") newDATA=CONCAT(CE,FT,TR).
> VARIABLE LABELS  newDATA 'IF (CE = "CE" | FT = "FT" | TR = "TR")
> newDATA=CONCAT(CE,FT,TR) '.
> EXECUTE.
>
>
> Thanks in advance,
>
> Michelle K.
>
> =====================
> 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
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: Concatenate

Albert-Jan Roskam
In reply to this post by subscribe SPSSX-l Anonymous-2
Interesting. I didn't know MAX could also be used for string vars. How does that work internally? Are the corresponding ASCII values compared?

Albert-Jan

--- On Mon, 3/16/09, Art Kendall <[hidden email]> wrote:

> From: Art Kendall <[hidden email]>
> Subject: Re: Concatenate
> To: [hidden email]
> Date: Monday, March 16, 2009, 11:36 PM
> Open a new instance of SPSS.
> Copy the syntax below to a syntax file.
> Click <run>. Click <all>.
>
> data list list /ConEd (a2)  FirstT (a2)  TRans
> (a2).
> begin data
> 'CE'
> 'CE'
> '' 'FT'
> '' 'FT'
> '' '' 'TR'
> end data.
>
> string newdata(a2).
> compute newdata = max(coned,firstt,trans).
> list.
>
> Art Kendall
> Social Research Consultants
>
>
> subscribe SPSSX-l Anonymous wrote:
> > Hello All,
> >
> > I have 3 variables which I recoded.  The three
> variables are mutually
> > exclusive and I'm trying to combine the 3 variables
> into 1.  However, when
> > I'm trying to concatenate the 3 variables together it
> only populates the
> > first variable I created (CE).  Do you know what
> I could be doing wrong?
> >
> > Current sample data:
> >
> > ConEd   FirstT   TRans
> > CE
> > CE
> >          FT
> >          FT
> >
>    TR
> >
>    TR
> >
> > Need the data to look like this:
> >
> > newDATA
> > CE
> > CE
> > FT
> > FT
> > TR
> > TR
> >
> > Below is what I was working with.
> >
> >
> > STRING CE (A2).
> > RECODE newCON_ED (1='CE') INTO CE.
> > VARIABLE LABELS  CE 'continuing ed'.
> > EXECUTE.
> >
> > STRING FT (A2).
> > RECODE newFIRST_TIME (1='FT') INTO FT.
> > VARIABLE LABELS  FT 'First-time'.
> > EXECUTE.
> >
> > STRING TR (A2).
> > RECODE newTRANSFER (1='TR') INTO TR.
> > VARIABLE LABELS  TR 'Transfer'.
> > EXECUTE.
> >
> > STRING  newDATA (A6).
> > IF  (CE = "CE" | FT = "FT" | TR = "TR")
> newDATA=CONCAT(CE,FT,TR).
> > VARIABLE LABELS  newDATA 'IF (CE = "CE" | FT =
> "FT" | TR = "TR")
> > newDATA=CONCAT(CE,FT,TR) '.
> > EXECUTE.
> >
> >
> > Thanks in advance,
> >
> > Michelle K.
> >
> > =====================
> > 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
>

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

Art Kendall
If I recall correctly, ascii was deliberately designed so that alpha characters would sort as US English  users would expect. blank 0 to 9 A to Z a to z.
 SPSS sorts blank 0 to 9 A a B b C c  not blank 0 to 9 A B C a b c as ASCII would.
I do not recall what happens with other printing character and with non-printing characters.

However the <help> says:
• For string values, “less than” and “greater than” results can vary by locale even for the same set of characters, since the national collating sequence is used. Language order, not ASCII order, determines where certain characters fall in the sequence.

show locale.
Tells what locale you have set.

I don't know if there is a way to show the collating sequence for a locale other than creating cases with 1 character  and sorting the variable ascending and descending to look at it.
I am cc'ing this to Jon, odds are that he has that info at his finger tips.

Art Kendall

Albert-jan Roskam wrote:
Interesting. I didn't know MAX could also be used for string vars. How does that work internally? Are the corresponding ASCII values compared?

Albert-Jan

--- On Mon, 3/16/09, Art Kendall [hidden email] wrote:

  
From: Art Kendall [hidden email]
Subject: Re: Concatenate
To: [hidden email]
Date: Monday, March 16, 2009, 11:36 PM
Open a new instance of SPSS.
Copy the syntax below to a syntax file.
Click <run>. Click <all>.

data list list /ConEd (a2)  FirstT (a2)  TRans
(a2).
begin data
'CE'
'CE'
'' 'FT'
'' 'FT'
'' '' 'TR'
end data.

string newdata(a2).
compute newdata = max(coned,firstt,trans).
list.

Art Kendall
Social Research Consultants


subscribe SPSSX-l Anonymous wrote:
    
Hello All,

I have 3 variables which I recoded.  The three
      
variables are mutually
    
exclusive and I'm trying to combine the 3 variables
      
into 1.  However, when
    
I'm trying to concatenate the 3 variables together it
      
only populates the
    
first variable I created (CE).  Do you know what
      
I could be doing wrong?
    
Current sample data:

ConEd   FirstT   TRans
CE
CE
         FT
         FT

      
   TR
    
   TR
    
Need the data to look like this:

newDATA
CE
CE
FT
FT
TR
TR

Below is what I was working with.


STRING CE (A2).
RECODE newCON_ED (1='CE') INTO CE.
VARIABLE LABELS  CE 'continuing ed'.
EXECUTE.

STRING FT (A2).
RECODE newFIRST_TIME (1='FT') INTO FT.
VARIABLE LABELS  FT 'First-time'.
EXECUTE.

STRING TR (A2).
RECODE newTRANSFER (1='TR') INTO TR.
VARIABLE LABELS  TR 'Transfer'.
EXECUTE.

STRING  newDATA (A6).
IF  (CE = "CE" | FT = "FT" | TR = "TR")
      
newDATA=CONCAT(CE,FT,TR).
    
VARIABLE LABELS  newDATA 'IF (CE = "CE" | FT =
      
"FT" | TR = "TR")
    
newDATA=CONCAT(CE,FT,TR) '.
EXECUTE.


Thanks in advance,

Michelle K.

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

    

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

Peck, Jon

The sort order actually doesn't have much connection with the numerical values of the characters anymore.  Starting with version 16, we use the Unicode collating rules whether or not you are in Unicode mode.  We do this so that you get the same sort whether you are in code page or Unicode mode.  The same characters may sort in a different order depending on the locale.  For example, in a US English, German, or Dutch locale, you get the following order.

 

á Á à Ǻ Ä a A b B c C

 

In a Danish locale, on the other hand, you get

 

Á á à A a B b C c Ä Ǻ

 

In a French locale, you get

á Á Ǻ à Ä a A b B c C

 

I leave it as an exercise for the reader what happens when you mix Japanese, European, Hebrew, and other interesting scripts together.

 

All of these are intended to be nationally appropriate, although standards tend to run out of steam when defining the order for characters that would rarely occur together.  There are many other interesting questions when you use a worldwide character set as in Unicode.

 

HTH,

Jon Peck

 

 

 

 

 

 

 


From: Art Kendall [mailto:[hidden email]]
Sent: Tuesday, March 17, 2009 7:17 AM
To: Albert-jan Roskam
Cc: [hidden email]; Peck, Jon
Subject: Re: Concatenate

 

If I recall correctly, ascii was deliberately designed so that alpha characters would sort as US English  users would expect. blank 0 to 9 A to Z a to z.
 SPSS sorts blank 0 to 9 A a B b C c  not blank 0 to 9 A B C a b c as ASCII would.
I do not recall what happens with other printing character and with non-printing characters.

However the <help> says:
• For string values, “less than” and “greater than” results can vary by locale even for the same set of characters, since the national
collating sequence is used. Language order, not ASCII order, determines where certain characters fall in the sequence.

show locale.
Tells what locale you have set.

I don't know if there is a way to show the collating sequence for a locale other than creating cases with 1 character  and sorting the variable ascending and descending to look at it.
I am cc'ing this to Jon, odds are that he has that info at his finger tips.

Art Kendall

Albert-jan Roskam wrote:

Interesting. I didn't know MAX could also be used for string vars. How does that work internally? Are the corresponding ASCII values compared?
 
Albert-Jan
 
--- On Mon, 3/16/09, Art Kendall [hidden email] wrote:
 
  
From: Art Kendall [hidden email]
Subject: Re: Concatenate
To: [hidden email]
Date: Monday, March 16, 2009, 11:36 PM
Open a new instance of SPSS.
Copy the syntax below to a syntax file.
Click <run>. Click <all>.
 
data list list /ConEd (a2)  FirstT (a2)  TRans
(a2).
begin data
'CE'
'CE'
'' 'FT'
'' 'FT'
'' '' 'TR'
end data.
 
string newdata(a2).
compute newdata = max(coned,firstt,trans).
list.
 
Art Kendall
Social Research Consultants
 
 
subscribe SPSSX-l Anonymous wrote:
    
Hello All,
 
I have 3 variables which I recoded.  The three
      
variables are mutually
    
exclusive and I'm trying to combine the 3 variables
      
into 1.  However, when
    
I'm trying to concatenate the 3 variables together it
      
only populates the
    
first variable I created (CE).  Do you know what
      
I could be doing wrong?
    
Current sample data:
 
ConEd   FirstT   TRans
CE
CE
         FT
         FT
 
      
   TR
    
   TR
    
Need the data to look like this:
 
newDATA
CE
CE
FT
FT
TR
TR
 
Below is what I was working with.
 
 
STRING CE (A2).
RECODE newCON_ED (1='CE') INTO CE.
VARIABLE LABELS  CE 'continuing ed'.
EXECUTE.
 
STRING FT (A2).
RECODE newFIRST_TIME (1='FT') INTO FT.
VARIABLE LABELS  FT 'First-time'.
EXECUTE.
 
STRING TR (A2).
RECODE newTRANSFER (1='TR') INTO TR.
VARIABLE LABELS  TR 'Transfer'.
EXECUTE.
 
STRING  newDATA (A6).
IF  (CE = "CE" | FT = "FT" | TR = "TR")
      
newDATA=CONCAT(CE,FT,TR).
    
VARIABLE LABELS  newDATA 'IF (CE = "CE" | FT =
      
"FT" | TR = "TR")
    
newDATA=CONCAT(CE,FT,TR) '.
EXECUTE.
 
 
Thanks in advance,
 
Michelle K.
 
=====================
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
 
    
 
=====================
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: Concatenate

Art Kendall
Is there a way for a user to find out what the sort order is without making up a dummy file and sorting it?

Art Kendall

Peck, Jon wrote:

The sort order actually doesn't have much connection with the numerical values of the characters anymore. � Starting with version 16, we use the Unicode collating rules whether or not you are in Unicode mode. � We do this so that you get the same sort whether you are in code page or Unicode mode.� The same characters may sort in a different order depending on the locale. � For example, in a US English, German, or Dutch locale, you get the following order.

á Á � Ǻ Ä a A b B c C

In a Danish locale, on the other hand, you get

Á á � A a B b C c Ä Ǻ

In a French locale, you get

á Á Ǻ � Ä a A b B c C

I leave it as an exercise for the reader what happens when you mix Japanese, European, Hebrew, and other interesting scripts together.

All of these are intended to be nationally appropriate, although standards tend to run out of steam when defining the order for characters that would rarely occur together.� There are many other interesting questions when you use a worldwide character set as in Unicode.

HTH,

Jon Peck


From: Art Kendall [mailto:[hidden email]]
Sent: Tuesday, March 17, 2009 7:17 AM
To: Albert-jan Roskam
Cc: [hidden email]; Peck, Jon
Subject: Re: Concatenate

If I recall correctly, ascii was deliberately designed so that alpha characters would sort as US English� users would expect. blank 0 to 9 A to Z a to z.
� SPSS sorts blank 0 to 9 A a B b C c� not blank 0 to 9 A B C a b c as ASCII would.
I do not recall what happens with other printing character and with non-printing characters.

However the <help> says:
•� For string values, “less than” and “greater than” results can vary by locale even for the same set of characters, since the national
collating sequence is used. Language order, not ASCII order, determines where certain characters fall in the sequence.

show locale.
Tells what locale you have set.

I don't know if there is a way to show the collating sequence for a locale other than creating cases with 1 character� and sorting the variable ascending and descending to look at it.
I am cc'ing this to Jon, odds are that he has that info at his finger tips.

Art Kendall

Albert-jan Roskam wrote:

Interesting. I didn't know MAX could also be used for string vars. How does that work internally? Are the corresponding ASCII values compared?
Albert-Jan
--- On Mon, 3/16/09, Art Kendall [hidden email] wrote:
From: Art Kendall [hidden email]
Subject: Re: Concatenate
To: [hidden email]
Date: Monday, March 16, 2009, 11:36 PM
Open a new instance of SPSS.
Copy the syntax below to a syntax file.
Click <run>. Click <all>.
data list list /ConEd (a2)�  FirstT (a2)�  TRans
(a2).
begin data
'CE'
'CE'
'' 'FT'
'' 'FT'
'' '' 'TR'
end data.
string newdata(a2).
compute newdata = max(coned,firstt,trans).
list.
Art Kendall
Social Research Consultants
subscribe SPSSX-l Anonymous wrote:
� � �  
Hello All,
I have 3 variables which I recoded.�  The three
� � � � �  
variables are mutually
� � �  
exclusive and I'm trying to combine the 3 variables
� � � � �  
into 1.�  However, when
� � �  
I'm trying to concatenate the 3 variables together it
� � � � �  
only populates the
� � �  
first variable I created (CE).�  Do you know what
� � � � �  
I could be doing wrong?
� � �  
Current sample data:
ConEd� �  FirstT� �  TRans
CE
CE
� � � � � � � �  FT
� � � � � � � �  FT
� � � � �  
� �  TR
� � �  
� � � TR
� � �  
Need the data to look like this:
newDATA
CE
CE
FT
FT
TR
TR
Below is what I was working with.
STRING CE (A2).
RECODE newCON_ED (1='CE') INTO CE.
VARIABLE LABELS�  CE 'continuing ed'.
EXECUTE.
STRING FT (A2).
RECODE newFIRST_TIME (1='FT') INTO FT.
VARIABLE LABELS�  FT 'First-time'.
EXECUTE.
STRING TR (A2).
RECODE newTRANSFER (1='TR') INTO TR.
VARIABLE LABELS�  TR 'Transfer'.
EXECUTE.
STRING�  newDATA (A6).
IF�  (CE = "CE" | FT = "FT" | TR = "TR")
� � � � �  
newDATA=CONCAT(CE,FT,TR).
� � �  
VARIABLE LABELS�  newDATA 'IF (CE = "CE" | FT =
� � � � �  
"FT" | TR = "TR")
� � �  
newDATA=CONCAT(CE,FT,TR) '.
EXECUTE.
Thanks in advance,
Michelle K.
=====================
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
� � �  
=====================
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: Concatenate

Peck, Jon

With over 100,000 characters and zillions of locales, there isn't any easy way to summarize these in a table.  We probably ought to have some sample orders in the CSR, but they aren't there currently.  Using a test dataset in the locale(s) you are concerned about is probably the best practical solution, but you can find the algorithmic rules starting here.  Be warned: it's kind of overwhelming, and this reference doesn't even get to the locale issue.

http://unicode.org/charts/collation/

 

You can find "European" alphabet charts at

http://www.evertype.com/alphabets/#1.2

 

also rather overwhelming but showing locale variations.  This may not be exactly the same as the collation rules we use, but it should give you a good start.  It covers about 160 languages (including Esperanto!) but none of the large character set languages (Japanese, Traditional and Simplified Chinese, and Korean).

 

HTH,

Jon

 

 


From: Art Kendall [mailto:[hidden email]]
Sent: Tuesday, March 17, 2009 8:32 AM
To: Peck, Jon
Cc: [hidden email]
Subject: Re: Concatenate

 

Is there a way for a user to find out what the sort order is without making up a dummy file and sorting it?

Art Kendall

Peck, Jon wrote:

The sort order actually doesn't have much connection with the numerical values of the characters anymore.  Starting with version 16, we use the Unicode collating rules whether or not you are in Unicode mode.  We do this so that you get the same sort whether you are in code page or Unicode mode.  The same characters may sort in a different order depending on the locale.  For example, in a US English, German, or Dutch locale, you get the following order.

 

á Á à Ǻ Ä a A b B c C

 

In a Danish locale, on the other hand, you get

 

Á á à A a B b C c Ä Ǻ

 

In a French locale, you get

á Á Ǻ à Ä a A b B c C

 

I leave it as an exercise for the reader what happens when you mix Japanese, European, Hebrew, and other interesting scripts together.

 

All of these are intended to be nationally appropriate, although standards tend to run out of steam when defining the order for characters that would rarely occur together.  There are many other interesting questions when you use a worldwide character set as in Unicode.

 

HTH,

Jon Peck

 

 

 

 

 

 

 


From: Art Kendall [mailto:[hidden email]]
Sent: Tuesday, March 17, 2009 7:17 AM
To: Albert-jan Roskam
Cc: [hidden email]; Peck, Jon
Subject: Re: Concatenate

 

If I recall correctly, ascii was deliberately designed so that alpha characters would sort as US English  users would expect. blank 0 to 9 A to Z a to z.
 SPSS sorts blank 0 to 9 A a B b C c  not blank 0 to 9 A B C a b c as ASCII would.
I do not recall what happens with other printing character and with non-printing characters.

However the <help> says:
• For string values, “less than” and “greater than” results can vary by locale even for the same set of characters, since the national
collating sequence is used. Language order, not ASCII order, determines where certain characters fall in the sequence.

show locale.
Tells what locale you have set.

I don't know if there is a way to show the collating sequence for a locale other than creating cases with 1 character  and sorting the variable ascending and descending to look at it.
I am cc'ing this to Jon, odds are that he has that info at his finger tips.

Art Kendall

Albert-jan Roskam wrote:

Interesting. I didn't know MAX could also be used for string vars. How does that work internally? Are the corresponding ASCII values compared?
 
Albert-Jan
 
--- On Mon, 3/16/09, Art Kendall [hidden email] wrote:
 
  
From: Art Kendall [hidden email]
Subject: Re: Concatenate
To: [hidden email]
Date: Monday, March 16, 2009, 11:36 PM
Open a new instance of SPSS.
Copy the syntax below to a syntax file.
Click <run>. Click <all>.
 
data list list /ConEd (a2)  FirstT (a2)  TRans
(a2).
begin data
'CE'
'CE'
'' 'FT'
'' 'FT'
'' '' 'TR'
end data.
 
string newdata(a2).
compute newdata = max(coned,firstt,trans).
list.
 
Art Kendall
Social Research Consultants
 
 
subscribe SPSSX-l Anonymous wrote:
    
Hello All,
 
I have 3 variables which I recoded.  The three
      
variables are mutually
    
exclusive and I'm trying to combine the 3 variables
      
into 1.  However, when
    
I'm trying to concatenate the 3 variables together it
      
only populates the
    
first variable I created (CE).  Do you know what
      
I could be doing wrong?
    
Current sample data:
 
ConEd   FirstT   TRans
CE
CE
         FT
         FT
 
      
   TR
    
   TR
    
Need the data to look like this:
 
newDATA
CE
CE
FT
FT
TR
TR
 
Below is what I was working with.
 
 
STRING CE (A2).
RECODE newCON_ED (1='CE') INTO CE.
VARIABLE LABELS  CE 'continuing ed'.
EXECUTE.
 
STRING FT (A2).
RECODE newFIRST_TIME (1='FT') INTO FT.
VARIABLE LABELS  FT 'First-time'.
EXECUTE.
 
STRING TR (A2).
RECODE newTRANSFER (1='TR') INTO TR.
VARIABLE LABELS  TR 'Transfer'.
EXECUTE.
 
STRING  newDATA (A6).
IF  (CE = "CE" | FT = "FT" | TR = "TR")
      
newDATA=CONCAT(CE,FT,TR).
    
VARIABLE LABELS  newDATA 'IF (CE = "CE" | FT =
      
"FT" | TR = "TR")
    
newDATA=CONCAT(CE,FT,TR) '.
EXECUTE.
 
 
Thanks in advance,
 
Michelle K.
 
=====================
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
 
    
 
=====================
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: Concatenate

Richard Ristow
In reply to this post by subscribe SPSSX-l Anonymous-2
This is old, but it doesn't look like the question posed was ever answered.

At 05:16 PM 3/16/2009, subscribe SPSSX-l Anonymous wrote:

I have 3 variables which I recoded.  The three variables are mutually exclusive. Current sample data:
|-----------------------------|---------------------------|
|Output Created               |12-APR-2009 21:38:21       |
|-----------------------------|---------------------------|
CE FT TR

CE
CE
   FT
   FT
      TR
      TR

Number of cases read:  6    Number of cases listed:  6

I'm trying to combine the 3 variables into 1.  However, when I'm trying to concatenate the 3 variables together it only populates the first variable I created (CE). Need the data to look like this:
newDATA
CE
CE
FT
FT
TR
TR

You catenated using the expression CONCAT(CE,FT,TR). Variable "CE" is two characters long even if there's nothing in it, the same for "FT". Catenate, and you'll get nothing but the value of "CE" in the first two characters, nothing but the value of "FT" in the next two, and the value of "TR" in the third two characters; see calculation of "newDATA", below. Use RTRIM to drop the blank values before catenating; see calculation of newDATA2.  Is this what you wanted?

STRING  newDATA (A6).
COMPUTE newDATA=CONCAT(CE,FT,TR).

STRING  newDATA2 (A6).
COMPUTE newDATA2=CONCAT(RTRIM(CE),RTRIM(FT),RTRIM(TR)).
LIST.

List
|-----------------------------|---------------------------|
|Output Created               |12-APR-2009 21:38:35       |
|-----------------------------|---------------------------|
CE FT TR newDATA newDATA2

CE       CE      CE
CE       CE      CE
   FT      FT    FT
   FT      FT    FT
      TR     TR  TR
      TR     TR  TR

Number of cases read:  6    Number of cases listed:  6
=============================
APPENDIX: Test data, and code
=============================
DATA LIST LIST/
     CE     FT       TR
    (A2,    A2,      A2).
BEGIN DATA   
    CE        .        .
    CE        .        .
    .        FT        .
    .        FT        .
    .         .       TR
    .         .       TR
END DATA.   

RECODE CE FT TR ('.' = ' ').
LIST.

STRING  newDATA (A6).
COMPUTE newDATA=CONCAT(CE,FT,TR).


STRING  newDATA2 (A6).
COMPUTE newDATA2=CONCAT(RTRIM(CE),RTRIM(FT),RTRIM(TR)).

LIST.

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

mils
In reply to this post by subscribe SPSSX-l Anonymous-2
DATA LIST LIST / CE (A2) FT (A2) TR (A2).
BEGIN DATA.
CE . .
CE . .
. FT  .
. FT  .
. . TR
. . TR
END DATA.
fre CE FT TR.

STRING  newDATA (A6).
COMPUTE newDATA=ltrim(REPLACE(CONCAT(rtrim(SUBSTR(CE,1,2)),rtrim(SUBSTR(FT,1,2)),rtrim(SUBSTR(TR,1,2))),'.',' ')).
fre newDATA.
mils
Reply | Threaded
Open this post in threaded view
|

Re: Concatenate

David Marso
Administrator
It seems that simply recoding the 3 variables "." -> " "
followed by MAX (see prev posts) would be a little better on the eyes.
--
mils wrote
DATA LIST LIST / CE (A2) FT (A2) TR (A2).
BEGIN DATA.
CE . .
CE . .
. FT  .
. FT  .
. . TR
. . TR
END DATA.
fre CE FT TR.

STRING  newDATA (A6).
COMPUTE newDATA=ltrim(REPLACE(CONCAT(rtrim(SUBSTR(CE,1,2)),rtrim(SUBSTR(FT,1,2)),rtrim(SUBSTR(TR,1,2))),'.',' ')).
fre newDATA.
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
|

Automatic reply: Concatenate

Cheryl Boglarsky
Banned User








I will be out of the office until Tuesday, March 19, 2013, with limited access to email. However, please know that your message is very important to me and I will respond when I return. 

 

 

 

Thank you.

 

Sincerely,

Cheryl

_____________________________________________________

Cheryl A. Boglarsky, Ph.D.

Human Synergistics, Inc.

39819 Plymouth Road

Plymouth, MI 48170

734.459.1030

[hidden email] 

 

 

This message includes legally privileged and confidential information that is intended only for the use of the recipient named above. All readers of this message, other than the intended recipient, are hereby notified that any dissemination, modification, distribution or reproduction of this e-mail is strictly forbidden.