SPSS Statistics

SPSS Statistics

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


#Analytics
#SPSSStatistics
#Analyticstools
 View Only
  • 1.  Data

    Posted 08/18/21 03:46 PM
    I have a pdf that i need to make useful.  I've converted the pdf to an excel file.  I have one variable that includes the word 'Math' or 'Language' randomly within the field.  But I need to flag each row beneath each 'Math' or 'Reading' to be 'Math' or 'Reading' correctly.  Hopefully this makes sense.  Thanks.

    ------------------------------
    Art Jack
    ------------------------------

    #SPSSStatistics


  • 2.  RE: Data

    Posted 08/18/21 03:56 PM
    Edited by System Admin 01/20/23 04:34 PM
    I for one am not clear.

    You have converted a PDF to an XLS(X?) file and brought it into SPSS. You have a single field (?), string I presume, that has text in each row. That text can (but need not) include either the word "Math" or the word "Language." You want another variable to have some kind of indicator telling you if a particular row has "Math", "Language," or neither. Really not sure about that last part....

    If so, you would use COMPUTE and the INDEX function to find the string value you want in text field. If you want, I can make an example syntax.

    If not, then I misunderstood.

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



  • 3.  RE: Data

    Posted 08/18/21 04:09 PM
    It looks like this.  Under grade there is one instance of Math, but i need to flag each row below it as math.  Until it gets to a 'Reading' in the same column and then flag reading.  This goes on for the length of the pdf/excel file.  

    Grade                 flag
    Math                 Math
    Growth                 Math
    ID Name DOB Gender Date Created/ SUtpadtuasted Status Math
    1 Art 21/8/18 M Math
    2 Jack 21/8/18 M 8/3/19 Math
    Grade                 Math
    Reading                 Reading
    Growth                 Reading
    ID Name DOB Gender Date Created/ SUtpadtuasted Status Reading
    1 Art 21/8/18 M 8/3/19 Reading
    2 Jack 21/8/18 M 8/3/19 Reading


    ------------------------------
    Art Jack
    ------------------------------



  • 4.  RE: Data

    Posted 08/18/21 04:22 PM
    OK then, so in pseudo-code:

    If "Math" in Field 1, COMPUTE flag="Math"
    If not "Math" in Field 1 but last flag="Math", keep the flag="Math"
    If "Reading" in Field 1, COMPUTE flag="Reading"
    If not "Reading" in Field 1 but last flag="Reading", keep the flag="Reading"

    Is that right?

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



  • 5.  RE: Data

    Posted 08/18/21 04:41 PM
    Edited by System Admin 01/20/23 04:40 PM
    So, assuming that is what you want done, ignore the way I created the data and variable names obviously, but use the syntax for the transformations.

    data list list /Grade (A12).
    begin data.
    Math	
    Growth	
    ID	
    1	
    2	
    Grade	
    Reading	
    Growth	
    ID	
    1	
    2	
    end data.
    
    string flag (A7).
    
    do if char.index(lower(grade),"math") > 0.
    compute flag="Math".
    else if char.index(lower(grade),"reading") > 0.
    compute flag="Reading".
    else.
    if lag(flag) = "Math" flag="Math".
    if lag(flag) = "Reading" flag="Reading".
    end if.
    
    
    list.​


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



  • 6.  RE: Data

    Posted 08/18/21 04:51 PM
    awesome, thanks

    ------------------------------
    Art Jack
    ------------------------------



  • 7.  RE: Data

    Posted 08/18/21 04:53 PM
    Check my revision. I forgot some logic that is gonna matter.

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



  • 8.  RE: Data

    Posted 08/18/21 04:41 PM
    Yes that sounds right.  With LEAD maybe.

    ------------------------------
    Art Jack
    ------------------------------