[an error occurred while processing this directive] EDS Training Manual - Reading data into SPSS

EDS Training Manual - Reading data into SPSS

. spss
printer friendly version Print
Page

Use the SPSS Wizard to Read an ASCII File

The SPSS Wizard for reading files will open automatically if you read in a text file.

  1. Fixed Format
     
    File Requirements: file has
    • one record per case
    • on each record the variables have the same starting and ending position
    • easiest to use when data in each field does not fill the field
    • not recommended for tightly packed data in lengthly records

     
    1. Fixed Format - suited to the Wizard
      Use file spss-tryit.txt. The accompanying documentation is spss-tryit.doc (you many not need it)
      Instruct SPSS to ignore the header rows (there are many of this before you get to data in fixed columns...look for the data rows.
      Every field in the SPSS file that you are creating needs to be numeric except for fields that are the component of Area Key, state (2 digits) and county (3 digits)s. In input they are in one field, in the SPSS file they need to be separate string fields.
      Except for state and county, use the defaulty variable names.

    2.  
    3. Fixed Format - a more difficult format
      Download the file spss-polljan13.dat. Use the print documentation to help you define the file with the SPSS Wizard.
     
  2. Excel Files
    As you can see from then list of file types, SPSS can open files in many formats.
    Find the DataGate Study for census data from Pakistan.
    Download the area population table for the North-West Frontier Province.
    Try opening it in SPSS.
    Decide whether it would be easier to clean the file up in Excel or SPSS.
    Once you have a usable file in SPSS, sort the data by average household size. Save the file as in SPSS portable format.
  3.  
  4. Delimited Format
     
    File Requirements:
    • delimited files are text files where individuals fields are enclosed with a some standard character, most often comma or tab
    • Files with extension .csv typically are comma delimited, that is commas between the numeric fields and " marking the text fields.
    • Delimited files can be opened in by the SPSS Wizard. Try opening the file stud-cdvols-jun22-07.csv.
    • Decide whether it is easier to use the wizard or to use EXCEL to convert the file to a xls first.
Read an ASCII File that is accompanied by SPSS Code

Read an ASCII File using code you create

For instructions, use the guide " What You Need to Know to Write an SPSS Program", specifically the section on raw data.

  1. Files with one record per case
    • Download the file (same data used in example the Wizard exercise) spss-polljan13.dat and the print documentation
    • Create a syntax file containing code that reads the variables. Do not worry about value labels.
    • Execute the code and save the file in either a .sav or .por format.

  2.  
  3. Files with multiple records per case
    • Use a Roper public opinion poll study comprised of a PDF codebook and a raw data file raw data file.
    • Create a syntax file containing Create code that reads the file and defines variables for all the background questions (q1-q2, q53-q62), questions on upcoming election (q22-26), questions on current office holders (q27-30), county, record number and all weight variables.
    • Once the file is in spss format run frequencies on a two or three variables and check it against the frequencies reported in the documentation. You may do this analysis using the windows menus or write code for it.

[an error occurred while processing this directive] Friday, 06-Jul-2007 09:24:47 EDT [an error occurred while processing this directive]