Using DATA LIST

The following table shows the organization of a grouped data file containing school subject scores for three students. Each student has three data records, and each record contains a score. The first record for each student also contains a case identifier. Records for each case are grouped together. Student 1 records appear first, followed by records for student 2 and student 3.

Record order determines whether a score is a reading, math, or science score. The reading score appears on the first record for a case, the math score appears on the second record, and the science score appears on the third record.

Table 1. Data for GROUPED.DAT
Student Score
1 58
1 59
1 97
2 43
2 88
2 45
3 67
3 75
3 90

Since each case has the same number of records and record order is fixed across cases, you can use DATA LIST to define the student data:

DATA LIST FILE='GROUPED.DAT' RECORDS=3
 /STUDENT 1 READING 5-6
 /MATH    5-6
 /SCIENCE 5-6.

LIST.
  • DATA LIST indicates that data are in file GROUPED.DAT.
  • RECORDS defines three records per case. The program reads student ID number (STUDENT) and reading score (READING) in the first record for a case. Math and science scores are read in the second and third records.
  • The output from the LIST command is shown below.
Figure 1. LIST output for GROUPED.DAT
STUDENT READING MATH SCIENCE

   1       58    59     97
   2       43    88     45
   3       67    75     90