SPSS Statistics

SPSS Statistics

Your hub for statistical analysis, data management, and data documentation. Connect, learn, and share with your peers! 

 View Only
  • 1.  Vectoring categorical

    Posted Mon February 28, 2022 09:42 AM

    Good morning, readers, mods. I'm quite stomped on my scripting on how combine categorical fields. So basically, I want to combine the value of reach_1 to 7 and store it to REACDUM field.

    Thanks in advance. :) 



    ------------------------------
    Irie Wila
    ------------------------------


    #SPSSStatistics


  • 2.  RE: Vectoring categorical

    Posted Mon February 28, 2022 10:05 AM
    My data for testing...
    dataset close all.
    data list free /reach_1 to reach_7 (7F1).
    begin data.
    1 0 1 0 5 0 4
    0 9 9 9 5 4 6
    0 0 0 0 1 2 3
    0 1 2 1 8 0 9
    0 0 1 0 0 4 1
    end data.
    recode all (0=sysmis).

    ****.

    string reach (A7).
    compute reach="".

    vector #v=reach_1 to reach_7.
    loop #i=1 to 7.
    do if #i < 7.
    if not(sysmis(#v(#i))) reach=concat(reach,string(#v(#i),F1),",").
    else.
    if not(sysmis(#v(#i))) reach=concat(reach,string(#v(#i),F1)).
    end if.
    end loop.

    list.

    ****.

    ------------------------------
    Rick Marcantonio
    Quality Assurance
    IBM
    ------------------------------



  • 3.  RE: Vectoring categorical

    Posted Mon February 28, 2022 01:45 PM

    Hi Rick, thank you for replying, upon running these scripts reach dummy data seems to be empty. 



    ------------------------------
    Irie Wila
    ------------------------------



  • 4.  RE: Vectoring categorical

    Posted Mon February 28, 2022 01:48 PM
    Hm. The reach_N variables look like numerics, with system-missing values. That's what I tested. My syntax should work. Did you get any error messages?

    ------------------------------
    Rick Marcantonio
    Quality Assurance
    IBM
    ------------------------------



  • 5.  RE: Vectoring categorical

    Posted Mon February 28, 2022 01:50 PM
    Probably need an EXEC command to see the result.
    --





  • 6.  RE: Vectoring categorical

    Posted Mon February 28, 2022 01:51 PM
    Yes, that must be it. I could/should have included an EXECUTE command. I used LIST, but then I used my own test data.

    ------------------------------
    Rick Marcantonio
    Quality Assurance
    IBM
    ------------------------------



  • 7.  RE: Vectoring categorical

    Posted Mon February 28, 2022 02:13 PM

    Hi Rick, thank you for your response. I did not get an error response. I included Execute command but to no avail.

    string reach (A7).
    compute reach="".

    vector #v=reach_1 to reach_7.
    loop #i=1 to 7.
    do if #i < 7.
    if not(sysmis(#v(#i))) reach=concat(reach,string(#v(#i),F1),",").
    else.
    if not(sysmis(#v(#i))) reach=concat(reach,string(#v(#i),F1)).
    end if.
    end loop.
    execute.

    list reach_1 to reach_7 reach.



    ------------------------------
    Irie Wila
    ------------------------------



  • 8.  RE: Vectoring categorical

    Posted Mon February 28, 2022 02:17 PM
    Please run
    DESCRIPTIVES reach_1 to reach_7.
    and tell me what you get.

    ------------------------------
    Rick Marcantonio
    Quality Assurance
    IBM
    ------------------------------



  • 9.  RE: Vectoring categorical

    Posted Mon February 28, 2022 03:10 PM
    Hi Rick, below is the result.



    ------------------------------
    Irie Wila
    ------------------------------