(defun read-list-char (file) (do ((char-list nil (append char-list (list new-char))) (new-char (read-char file) (read-char file))) ((or (eql new-char #\Newline) (null new-char)) char-list))) (defun write-list-char (char-list file) (dolist (char char-list) (write-char char file)) (write-char #\Space file)) (defun read-select-write (ind in-stream out-stream) (let* ((line (read-list-char in-stream)) (char-lists (if line (mapcar #'(lambda (i) (select line i)) ind)))) (dolist (char-list char-lists line) (write-list-char char-list out-stream)))) (defun grab-nels88 (sex-ind ind1 ind2 ind3 out-file) (let ((sex (open "sexrace.dat")) (f (open "nels88_2.dat")) (out (open out-file :direction :output))) (loop (unless (read-select-write sex-ind sex out) (return)) (read-select-write ind1 f out) (read-select-write ind2 f out) (read-select-write ind3 f out) (write-char #\Newline out)) (write-char #\Newline out) (close sex) (close f) (close out))) (def var-labels (list "School ID" "Student ID" "Sex" "Race" "BYS79A" "G8CTRL" "SES" "BYPARED" "Math" "BYSC47D" "BYSCENRL" "Urban" "Region" "Minority" "Ratio")) (grab-nels88 (list (iseq 0 4) '(5 6) '(8) '(10)) (list (iseq 17 18) '(38) (iseq 39 44) '(45) (iseq 57 63)) nil (list '(10) '(43) '(45) '(46) '(47) '(49 50)) "multi2.dat")