find a string in a STRG variable

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

find a string in a STRG variable

drfg2008
SPSS20

I have a STRG variable VAR001 in which different words are listed. I would like to search the STRG variable VAR001 for a certain text (string), i.e. "hallo". If the string is found a second variable (VAR002) should get the value 1. If not: 0.







Dr. Frank Gaeth

Reply | Threaded
Open this post in threaded view
|

Re: find a string in a STRG variable

Art Kendall
something like (untested)
compute var002 = char.index(var001,'hallo') ne 0.
Art Kendall
Social Research Consultants
On 3/16/2014 1:19 PM, drfg2008 [via SPSSX Discussion] wrote:
SPSS20

I have a STRG variable VAR001 in which different words are listed. I would like to search the STRG variable VAR001 for a certain text (string), i.e. "hallo". If the string is found a second variable (VAR002) should get the value 1. If not: 0.







Dr. Frank Gaeth
FU-Berlin



If you reply to this email, your message will be added to the discussion below:
http://spssx-discussion.1045642.n5.nabble.com/find-a-string-in-a-STRG-variable-tp5724892.html
To start a new topic under SPSSX Discussion, email [hidden email]
To unsubscribe from SPSSX Discussion, click here.
NAML

Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: find a string in a STRG variable

David Marso
Administrator
Adding to this, if you have multiple strings or multiple variables consider setting this up in a DO REPEAT.
===
Art Kendall wrote
something like
        (untested)
        compute var002 = char.index(var001,'hallo') ne 0.
     
      Art Kendall
Social Research Consultants
      On 3/16/2014 1:19 PM, drfg2008 [via SPSSX Discussion] wrote:
   
     SPSS20
     
     
      I have a STRG variable VAR001 in which different words are listed.
      I would like to search the STRG variable VAR001 for a certain text
      (string), i.e. "hallo". If the string is found a second variable
      (VAR002) should get the value 1. If not: 0.
     
     
     
     
     
     
     
     
       Dr. Frank
        Gaeth
       
        FU-Berlin
       
     
     
     
     
     
        If you reply to this email, your
          message will be added to the discussion below:
        http://spssx-discussion.1045642.n5.nabble.com/find-a-string-in-a-STRG-variable-tp5724892.html 
     
     
        To start a new topic under SPSSX Discussion, email
        [hidden email] 
        To unsubscribe from SPSSX Discussion, click
          here .
        NAML
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?"