Global AI and Data Science

Global AI & Data Science

Train, tune and distribute models with generative AI and machine learning capabilities

 View Only
  • 1.  Creating Categorical Variable with IF Command

    Posted Wed June 19, 2024 09:33 AM

    Hello, I am a doctoral student and need help with SPSS syntax. I would like to create a categorical variable that includes all 4 disability types (deafness [DEAF], blindness [BLIND], learning disabilities [LRD], and physical disabilities[PHYS]). The binary disability variables are coded identically: 1=WITH DISABILITY, 0=NO DISABILITY. When I enter the following syntax however, I do not get the same n of students with disability in the newly created DIS variable as the n in each of the original variables. For instance, in the original DEAF variable, 238 students reported being deaf or hard of hearing. But in the new DIS variable, there are only 179 students. 

     Compute DIS=99. 

     
    if (deaf=1) DIS=1.
    execute.
     
    if (blind=1) DIS=2. 
    EXECUTE.
     
    IF (LRC=1) DIS=3. 
    EXECUTE.
     
    IF (PHYS=1) DIS=4. 
    EXECUTE. 
     
    RECODE 
        DIS
        (99=SYSMIS).
     
    VALUE LABELS DIS
        1 'Deaf'
        2 'Blind' 
        3 'LRD' 
        4 'PHYS'.
     
    Freq vars=dis deaf blind lrc phys/stat=min max mean stddev. 
    -----------------------------------------------------------END SYNTAX-----------------------------------------------------
    Can someone please tell me what I am doing wrong?
    Thanks in advance!



    ------------------------------
    Carrie Badillo
    ------------------------------


    #AIandDSSkills


  • 2.  RE: Creating Categorical Variable with IF Command

    Posted Mon July 22, 2024 03:48 PM

    Hi Carrie,

    I apologize for the delay in responding, the SPSS product has its own community.

    Were you able to get assistance with your issue?

    Thanks,

    Nick



    ------------------------------
    Nick Plowden
    AI Community Engagement
    IBM
    ------------------------------