Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
The ASSIGN Procedure

Example 2.3: Minimizing Swim Times

A swimming coach needs to assign male and female swimmers to each stroke of a medley relay team. The swimmers' best times for each stroke are stored in a SAS data set. The ASSIGN procedure is used to evaluate the times and to match strokes and swimmers to minimize the total relay swim time. The following statements produce Output 2.3.1:

   title 'Assigning Strokes Using the BY Statement';

   data relay;
      input name $ sex $ back breast fly free;
      datalines;
SUE     F 35.1 36.7 28.3 36.1
KAREN   F 34.6 32.6 26.9 26.2
JAN     F 31.3 33.9 27.1 31.2
ANDREA  F 28.6 34.1 29.1 30.3
CAROL   F 32.9 32.2 26.6 24.0
ELLEN   F 27.8 32.5 27.8 27.0
JIM     M 26.3 27.6 23.5 22.4
MIKE    M 29.0 24.0 27.9 25.4
SAM     M 27.2 33.8 25.2 24.1
CLAYTON M 27.0 29.2 23.0 21.9
   ;

   proc assign out=fast;
      cost back--free;
      id name;
      by sex;

   proc print;
      by sex;
      sum _fcost_;
   run;

Output 2.3.1: Assigning Strokes Using the BY Statement

Assigning Strokes Using the BY Statement

sex=F

Obs name back breast fly free _ASSIGN_ _FCOST_
1 SUE 35.1 36.7 28.3 36.1   0.0
2 KAREN 34.6 32.6 26.9 26.2 breast 32.6
3 JAN 31.3 33.9 27.1 31.2 fly 27.1
4 ANDREA 28.6 34.1 29.1 30.3   0.0
5 CAROL 32.9 32.2 26.6 24.0 free 24.0
6 ELLEN 27.8 32.5 27.8 27.0 back 27.8
sex             111.5

sex=M

Obs name back breast fly free _ASSIGN_ _FCOST_
7 JIM 26.3 27.6 23.5 22.4 free 22.4
8 MIKE 29.0 24.0 27.9 25.4 breast 24.0
9 SAM 27.2 33.8 25.2 24.1 back 27.2
10 CLAYTON 27.0 29.2 23.0 21.9 fly 23.0
sex             96.6
              208.1


On the basis of this solution, Jim will swim freestyle, Mike will swim breast stroke, Sam will swim back stroke, and Clayton will swim butterfly. For the women's team, Karen will swim breast stroke, Jan will swim butterfly, Carol will swim freestyle, and Ellen will swim back stroke.

Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Top
Top

Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.