by Brad Phillips
The following command file enables you to take multiple records in a file and reduce it to one record.
Line 1 *computes only one case from multiple cases.
Line 2 sort cases by stdid.
Line 3 compute junk=1.
Line 4 if (stdid = lag(stdid)) junk=0.
Line 5 select if (junk=1).
Line 1 is simply a comment statement.
Line 2 sorts the cases by student ID number. Please note that you can sort on any variable of interest.
Line 3 computes a new variable known as ‘junk’ and assigns a value to every case of 1
Line 4 tells the computer to assign a 0 to every cases after the first case in a series, such as student identifier.
Line 5 select only the first case in the series and drops all other.
This little set of commands is very useful when you want demographic data by headcount not enrollment, and must delete multiple records.