Newsgroups: bit.listserv.spssx-l
Date:         Fri, 10 Apr 1992 16:52:50 ECT
Reply-To:     Lary Jones <LJONES@BINGVMB.BITNET>
From:         Lary Jones <LJONES@BINGVMB.BITNET>
Subject:      Mixed Fixed and Free I/O

Recently, a faculty member on our campus gave me an interesting problem
to work on. I am not sure that I have the best approach to the problem,
but I will share what I passed on, in the hope that others might have
some ideas.  I think the problem, and what I have done so far, may
be a good illustration of the capabilities, and limitations, of SPSS
as compared to SAS.

Respond to the list or me, personally.  If you respond to me personally,
please indicate whether you feel comfortable having your ideas shared.

Thanks,
__________________________________________________________________
Lary Jones...Computing Services...Binghamton Univ...(607) 777-2879
School of Management Research Support ...... LJones@BingVMB.Bitnet
  ==============================================================
Tom,

You asked if SPSS could read a file where there are two records per
case, the first of which is freefield text, and a second which contains
fixed column numeric data, without spaces. I have broken your question
into two parts:

1) Reading a variable format record followed by a fixed format record

   No problem here:

   INPUT PROGRAM.
   DATA LIST  File=filename  LIST
      / Lastname (A12)  Firstname (A12)  Sex (A1) stuff junk *
   DATA LIST  File=filename
      / var1 to var10 1-20
   End Case
   End Input Program

   Actually, I think you can read two parts of the same record with
   different formats using REREAD (as long as the fixed part occurrs
   within reliable columns).  For example, if you had some fixed data
   followed by a freefield name and/or address, you could use something
   like the following:

   INPUT PROGRAM.
   DATA LIST  File=filename
      / ID 1-3 var1 to var10 6-15
   REREAD COLUMN 16
   DATA LIST  File=filename  LIST
      / Lastname (A12)  Firstname (A12)  Sex (A1)
   End Case
   End Input Program

   This will read an ID number from cols. 1-3, 10 data fields in cols.
   6-15, and, starting in col. 16, begin reading last name and first
   name in free format.


2) Reading character/string values with embedded blanks when using
   FREE or LIST format.

   SPSS does not provide a direct way to read fields with embedded
   blanks under FREE or LIST input (without enclosing the whole string
   in quotes).  For example, if one is reading in last names, the name
   Van Dyke must appear as "Van Dyke" or must be read in via column
   location.

   The alternative is to read in a line (or part of a line) under a
   fixed format, and use string functions and programing commands to
   parse the line.

   I am checking with the SPSS Tech. Support line, but I think this is
   a case where SAS has an advantage.  The SAS command:

   INPUT last & $16. First $12.;

   which requires double spaces between the last name and first name
   to indicate the end of one, and the start of the other, seems simpler.
   If you choose to use SPSS for reasons of familiarity, I can provide
   whatever input language is required.  I will let you know if there is
   a better way to handle embedded blank fields in SPSS.

-Lary
Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU