Re: Reread - How can I create a case using reread?

Posted by Jon K Peck on
URL: http://spssx-discussion.165.s1.nabble.com/How-data-entry-for-TURF-analysis-tp4635246p4657285.html

REREAD is really intended for cases where there are varying record formats, and once the record type is identified, typically via a field that in the same columns for each type, you can reread that record using the appropriate DATA LIST specifications.  It doesn't sound like that is the case here.  How do you know which field is which?  Do you just split the record on hex 1C values?  Hex 1C is the ascii "file separator" character?

Just splitting the data at each x1C value would be very simple with a little Python, but it seems that you still wouldn't know which field is which.  And is each field surrounded by 1C values, or is there just one at each field boundary?  How would you declare the width of these string variables?

Jon Peck
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621




From:        Rich Ulrich <[hidden email]>
To:        [hidden email]
Date:        08/01/2011 07:50 PM
Subject:        Re: [SPSSX-L] Reread - How can I create a case using reread?
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Why is there a need to do a re-read?

Read what you have as String and put the parts into a new set of variables,
placing the comments in the last variable if that is what you want;
and ignore the variables that you initially read in.  Why not?

You can apply a formatted read to any substring, if you want the
numeric translations.  That seems neater than generating a
complex format  on the fly, for re-read (if that is even possible).

When you Save File, delete the original text variable.

--
Rich Ulrich

> Date: Mon, 1 Aug 2011 12:29:05 -0400
> From: [hidden email]
> Subject: Reread - How can I create a case using reread?
> To: [hidden email]
>
> Good Morning List,
>
> I am trying to build cases out of a file but am not very familiar with the reread function, so would appreciate any help with building cases out of raw data files with the following format:
>
> Data are text files with variable length records - not all fields are included in each record. Fields are delimited by the hex equivalent of '1C' and sometimes fields are followed by delimited comments, so they may appear as fields as well. There does not appear to be any pattern as to where the comments appear, except they are preceded by "FY" or "FQ" and have commas, hyphens, and periods interspersed throughout. Each record begins with a hex equivalent of '2' and ends with '3' (non printing characters); I can modify these, that is not a problem.
>
> I have tried doing this using Input Program, but lack of familiarity with "reread", my result is not applicable to the different files having different formats - very limited!
>
> Here is what I would like know: How would I go about looping through each record, building a case up, unless I find the comment, then reread past the comment, continue to build the case until I reach the end of the record, then reread in order to put the comment at the end of the case I am building?
>