Need help with search

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

Need help with search

Lombardo, Barbara

Hello,

 

I have a multi valued field that comes in looking like the following:

TR                     

TRýCD                  

TRýCDýCDýCDTR          

TR                     

TRýCD                  

TR                     

PE                     

TRýPE                  

JSýTRýCDJS             

 

Can someone tell me which function will get me the position of the first occurrence of ý from the right.  I have tried INDEX,RINDEX but this does not do it.

 

Thank you

 

Barbara

 

Reply | Threaded
Open this post in threaded view
|

Question about combining variables

stace swayne

Dear list,

 

I have two variables, (1) Chile (Chile coded as 14) and (2) Argentina (Argentina coded as 15),

 

I would like to combine them into one variable called Country (and recode them into Chile =0 and Argentina =1).

 

Can someone suggest syntax for doing this,

 

All suggestions are appreciated,

 

Stace

 

 


Reply | Threaded
Open this post in threaded view
|

Re: Question about combining variables

John F Hall
Not sure what your variable name is for the country, but something like...
 
compute country = 2.
if chile = 14 country = 0.
if argentina = 15 country = 1.
val lab 0 'Chile' 1 'Argentina' 2 'Other'.
freq country.
 
 
----- Original Message -----
Sent: Monday, September 14, 2009 4:35 PM
Subject: Question about combining variables

Dear list,

 

I have two variables, (1) Chile (Chile coded as 14) and (2) Argentina (Argentina coded as 15),

 

I would like to combine them into one variable called Country (and recode them into Chile =0 and Argentina =1).

 

Can someone suggest syntax for doing this,

 

All suggestions are appreciated,

 

Stace

 

 


Reply | Threaded
Open this post in threaded view
|

Re: Question about combining variables

John F Hall
Stace
 
No problem.  Pleased to be of help. 
Check me out on:
 
 
You can find all my SPSS learning materials on:
 
 
There's loads more in preparation: keeps me from going senile in retirement.
 
John Hall
 
 
----- Original Message -----
Sent: Monday, September 14, 2009 7:08 PM
Subject: Re: Question about combining variables

thanks, the syntax worked
 
stace


From: John F Hall <[hidden email]>
To: stace swayne <[hidden email]>; [hidden email]
Sent: Monday, September 14, 2009 11:15:22 AM
Subject: Re: Question about combining variables

Not sure what your variable name is for the country, but something like...
 
compute country = 2.
if chile = 14 country = 0.
if argentina = 15 country = 1.
val lab 0 'Chile' 1 'Argentina' 2 'Other'.
freq country.
 
 
----- Original Message -----
Sent: Monday, September 14, 2009 4:35 PM
Subject: Question about combining variables

Dear list,

 

I have two variables, (1) Chile (Chile coded as 14) and (2) Argentina (Argentina coded as 15),

 

I would like to combine them into one variable called Country (and recode them into Chile =0 and Argentina =1).

 

Can someone suggest syntax for doing this,

 

All suggestions are appreciated,

 

Stace

 

 



Reply | Threaded
Open this post in threaded view
|

Re: Need help with search

Bruce Weaver
Administrator
In reply to this post by Lombardo, Barbara
Lombardo, Barbara wrote
Hello,

I have a multi valued field that comes in looking like the following:

TR                      
TRýCD                  
TRýCDýCDýCDTR          
TR                      
TRýCD                  
TR                      
PE                      
TRýPE                  
JSýTRýCDJS              


Can someone tell me which function will get me the position of the first occurrence of ý from the right.  I have tried INDEX,RINDEX but this does not do it.


Thank you

Barbara
This worked for me (version 17.0.2, Windoze XP Pro).

data list list / stringvar (a15).
begin data
TR
TRýCD
TRýCDýCDýCDTR
TR
TRýCD
TR
PE
TRýPE
JSýTRýCDJS
end data.

compute pos = char.rindex(stringvar,"ý").
format pos (f2.0).
list.

Output (best viewed with a fixed font):

stringvar       pos
TR                0
TRýCD             3
TRýCDýCDýCDTR     9
TR                0
TRýCD             3
TR                0
PE                0
TRýPE             3
JSýTRýCDJS        6

Number of cases read:  9    Number of cases listed:  9

--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

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