SPSS Statistics

 View Only
Expand all | Collapse all

Selecting sequential variables and searching for multiple sequential string criteria SPSS version 28

  • 1.  Selecting sequential variables and searching for multiple sequential string criteria SPSS version 28

    Posted Fri March 24, 2023 09:31 AM

    Hello fellow SPSS users,

    I am looking for a way to select multiple sequential variables in an easier way than typing them all in. For example, I created variables a, b, c, and d with strings 'C###'. What I want to do is to select and search the variable as follow:

    * Example a.

    IF (a TO d) = 'C1## TO C2## var = 1'.

    The previous line does not work of course, but now if you want to code this you'd have to do it like:

    * Example b.

    IF (a = 'C101' OR a = 'C102' OR ... OR a = 'C200' OR

    b = 'C101' OR ... OR b = 'C200' OR

    ... OR d = 'C200') var = 1.

    For convenience I put in '...' as the code would otherwise be extremely long. I am looking for a way to code Example b as Example a.

    I don't mind converting the string 'C###' to a numeric without the C, but I don't know how to do this either.

    Thank you for taking the time to help me solve this problem in advance!

    Regards,

    S. Nahar

    #IBMSPSS 



    ------------------------------
    S. Nahar
    ------------------------------


  • 2.  RE: Selecting sequential variables and searching for multiple sequential string criteria SPSS version 28

    IBM Champion
    Posted Fri March 24, 2023 09:47 AM
    Look into DO REPEAT and into the any function.