SPSS Statistics

SPSS Statistics

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

 View Only
  • 1.  Problem reading a long non-delimited text file

    Posted Fri September 29, 2023 02:31 PM
      |   view attached

    I'm trying to read in a long text file (non-delimited with fixed column widths.  I keep getting the error:  
    >Error.  Command name: GET DATA 
    >(2265) Unrecognized or invalid variable format.  The format is invalid. 
    >For numeric formats, the width or decimals value may be invalid. 
    >Variable: 
    >Execution of this command stops.

    Unfortunately it doesn't give me a line number for the offending variable.  The syntax is very long so attached as a word doc.  

    Any help is greatly appreciated!



    ------------------------------
    jeanelle sheeder
    ------------------------------

    Attachment(s)

    docx
    GET DATAsyntax.docx   16 KB 1 version


  • 2.  RE: Problem reading a long non-delimited text file

    Posted Fri September 29, 2023 05:32 PM

    Hi @jeanelle sheeder

    Start by reviewing the GET DATA command syntax, specifically the /TYPE=TXT options.
    If you want to specify the start-end columns, use this syntax structure
    If you want to specify only the format, use this syntax structure

    Generally speaking, your text data likely does not correspond to the way you have it specified.  For instance, the error message references values with decimals.  Yet your GET DATA command defines no fields that include decimals.  Should it?



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



  • 3.  RE: Problem reading a long non-delimited text file

    Posted Fri September 29, 2023 05:40 PM

    Actually, i think i just got it figured out. I did only have one variable that had decimal places. The problem was variables that were only 1 character wide. Instead of putting just the position (like "23") you have to put 23-23. 

    Thanks for the help!

    Here's how my new code looks:

     
    GET DATA /TYPE = TXT
    /FILE = 'c:\1\nat2021usAllCnty.txt'
    /FIXCASE = 1
    /ARRANGEMENT = FIXED
    /FIRSTCASE = 1
    /IMPORTCASE = ALL
    /VARIABLES =
    /
    Fill1 1-8 A8
    DOB_YY 9-12 F4
    DOBMM 13-14 A2
    Fill2 15-18 A4
    DOB_TT 19-22 TIME5
    DOBWK 23-23 F1
    OSTATE 24-25 A2
    XOSTATE 26-27 A2
    OCNTYFIPS 28-30 A3
    OCNTYPOP 31-31 F1


    ------------------------------
    jeanelle sheeder
    ------------------------------