Reading Each Record in a Mixed File

The following example is for two hypothetical elementary school students referred to a remedial education teacher. Student 1, who was thought to need special reading attention, took reading tests (word identification and comprehension tests). The second student completed writing tests (handwriting, spelling, vocabulary, and grammar tests). Test code (READING or WRITING) indicates whether the record contains reading or writing scores.

The following commands define the test data:

FILE TYPE MIXED RECORD=TEST 1-7(A). 

RECORD TYPE 'READING'.
DATA LIST / ID  9-10 GRADE  12-13 WORD 15-16 COMPRE 18-19.

RECORD TYPE 'WRITING'. 
DATA LIST / ID  9-10 GRADE 12-13 HANDWRIT 15-16 SPELLING 18-19
            VOCAB 21-22 GRAMMAR  24-25.
END FILE TYPE.

BEGIN DATA
READING 1  04 65 35 
WRITING 2  03 50 55 30 25  
END DATA.

LIST.
  • FILE TYPE specifies that the data contain mixed record types. RECORD reads the record identifier (variable TEST) in columns 1 through 7.
  • One pair of RECORD TYPE and DATA LIST statements is coded for each record type in the file. The program reads variables ID, GRADE, WORD, and COMPRE in the record in which the value of TEST is READING, and ID, GRADE, HANDWRIT, SPELLING, VOCAB, and GRAMMAR in the WRITING record.
  • END FILE TYPE signals the end of file definition.
  • BEGIN DATA and END DATA indicate that data are inline. Data are mixed, since some column positions contain different variables for the two cases. For example, word identification score is recorded in columns 15 and 16 for student 1. For student 2, handwriting score is recorded in these columns.
  • The following figure shows the output from LIST. Missing values are assigned for variables that are not recorded for a case.
Figure 1. LIST output for mixed file
TEST    ID GRADE WORD COMPRE HANDWRIT SPELLING VOCAB GRAMMAR

READING  1    4   65    35       .        .       .      .
WRITING  2    3    .     .      50       55      30     25