SPSS Statistics

SPSS Statistics

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

 View Only
  • 1.  Trouble Importing from Excel to SPSS - Reading a String as Numeric and not Importing Correctly

    Posted Wed October 18, 2023 11:58 AM
      |   view attached

    I cannot seem to get my Excel file to Import into SPSS correctly for the Unique Identifier variable because the Unique Identifier variable has three different types of styles: (1) numeric numbers, (2) mix of numbers and letters, and (3) numbers so long excel automatically converted it into scientific notation (excel file attached). SPSS assumes I'm trying to import the Unique identifier as a numeric variable, so exactly 510 rows are imported with BLANKS in the unique identifier variable. I tried converting the scientific notation into their full numeric values but SPSS still reads the variable as a numeric variable and I can't get it to change. 

    My question is: How can I get SPSS to read this variable as a String so it doesn't delete any of the unique identifiers? The unique identifiers cannot change or be replaced (other than removing scientific notation) as they are important for merging with other data files. 

    This is the standard import syntax I've used thus far: 

    NEW FILE.
    DATASET NAME DataSet1 WINDOW=FRONT.
     
    GET DATA
      /TYPE=XLSX
      /FILE='C:\Users\Me\OneDrive - University of Nebraska at Omaha\UNO Research\2. GRACA\Branscum_2023 GRACA-K-12 SBH\Data Cleaning\Example Data.xlsx'
      /SHEET=name 'Study variables'
      /CELLRANGE=FULL
      /READNAMES=ON
      /DATATYPEMIN PERCENTAGE=95.0
      /HIDDEN IGNORE=YES.
    EXECUTE.
    DATASET NAME DataSet2 WINDOW=FRONT.
    SORT CASES BY UniqueIdentifier (A).



    ------------------------------
    Caralin Branscum
    ------------------------------

    Attachment(s)

    xlsx
    Example Data.xlsx   2.21 MB 1 version


  • 2.  RE: Trouble Importing from Excel to SPSS - Reading a String as Numeric and not Importing Correctly

    Posted Wed October 18, 2023 12:24 PM

    By the way - you can control F "CC" to find the 510 unique identifiers with letters in the excel file I attached. Thank you in advanced! 



    ------------------------------
    Caralin Branscum
    ------------------------------



  • 3.  RE: Trouble Importing from Excel to SPSS - Reading a String as Numeric and not Importing Correctly

    Posted Wed October 18, 2023 01:01 PM

    You can save it as a csv and choose numeric on the import for the key.



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



  • 4.  RE: Trouble Importing from Excel to SPSS - Reading a String as Numeric and not Importing Correctly

    Posted Wed October 18, 2023 01:28 PM
    Those missing cases look like numbers but are actually set as strings in Excel.  Select that entire column in Excel and in the Number group, on the Home ribbon, set them to Number. Safe the file and then read it in to SPSS.  All the cases actually were read with the sheet as is, but those IDs were lost.





  • 5.  RE: Trouble Importing from Excel to SPSS - Reading a String as Numeric and not Importing Correctly

    Posted Wed October 18, 2023 01:44 PM

    Thank you for the reply! I'm a little confused though. The document is already a CSV and I need the variable to read as a String but it is being read as a numeric variable, but I'm not sure how to change this. 



    ------------------------------
    Caralin Branscum
    ------------------------------



  • 6.  RE: Trouble Importing from Excel to SPSS - Reading a String as Numeric and not Importing Correctly

    Posted Wed October 18, 2023 02:06 PM
    Edited by Art Jack Wed October 18, 2023 02:24 PM

    If all the data is there just the wrong format just use ALTER TYPE and change it.



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



  • 7.  RE: Trouble Importing from Excel to SPSS - Reading a String as Numeric and not Importing Correctly

    Posted Fri October 20, 2023 11:58 AM

    Hi @Caralin Branscum,

    If your data is already ".csv" (rather than ".xlsx"):

    • Use the "File -> Import data -> CSV Data" menus.
    • On the first page of the import data wizard, use the "AdvancedOptions (Text Wizard) button.
    • Work your way through the wizard
    • When the wizard complains of the invalid variable name "UniqueIdentifier"
    • Take that opportunity to change the "Data format:" from "Automatic" to "String"
    • Voila!


    ------------------------------
    David Dwyer
    SPSS Technical Support
    IBM Software
    ------------------------------