Chapter Contents Previous Next
 The ASSIGN Procedure

## Introductory Example

Consider assigning five programmers to five programming jobs. Each programmer prefers specific programming jobs over others. You can use PROC ASSIGN to assign jobs to programmers in such a way that the total preferences of the group are maximized. Suppose you ask each programmer to rank the jobs according to preference (using 1 for the most preferred job and 5 for the least preferred job). PROC ASSIGN maximizes the total preference of the group by minimizing the sum of the preferences. In the matrix that follows, each row of the matrix represents a programmer and each column represents a programming job. Each entry in the matrix is a preference ranking each programmer given each programming job.

```   PRGMER   JOB1    JOB2    JOB3    JOB4    JOB5

PRGMER1   4       1       3       5       2
PRGMER2   2       1       3       4       5
PRGMER3   3       2       4       1       5
PRGMER4   2       3       4       5       1
PRGMER5   4       2       3       1       5
```

To solve this problem using PROC ASSIGN, the data must be in a SAS data set; the solution is output to a SAS data set and no output is produced. Each observation corresponds to a programmer and contains the programming job assigned to it. In this way, the procedure identifies the assignment of the five jobs to the five programmers. To solve this assignment problem, place the preference data into a SAS data set (PREFER). Then, call PROC ASSIGN, identifying the cost variables in the input data set. The solution is output by PROC ASSIGN to a SAS data set (PREFER1) and displayed with the PRINT procedure. The following statements produce Figure 2.1:

```   title 'Assigning Programming Jobs to Programmers';

data prefer;
input  prgmer \$ job1-job5;
datalines;
PRGMER1 4 1 3 5 2
PRGMER2 2 1 3 4 5
PRGMER3 3 2 4 1 5
PRGMER4 2 3 4 5 1
PRGMER5 4 2 3 1 5
;
proc assign data=prefer out=prefer1;
cost job1-job5;
id prgmer;
run;

proc print data=prefer1;
sum _fcost_;
run;
```

The following note is written to the SAS log:

```NOTE: The minimum cost assignment costs 8.
```

 Assigning Programming Jobs to Programmers

 Obs prgmer job1 job2 job3 job4 job5 _ASSIGN_ _FCOST_ 1 PRGMER1 4 1 3 5 2 job2 1 2 PRGMER2 2 1 3 4 5 job1 2 3 PRGMER3 3 2 4 1 5 job4 1 4 PRGMER4 2 3 4 5 1 job5 1 5 PRGMER5 4 2 3 1 5 job3 3 8

Figure 2.1: Assigning Programming Jobs to Programmers

The solution, given in column _ASSIGN_, shows how each programming job should be assigned to each worker in order to minimize the assignment cost, which is equivalent to maximizing the worker preferences. The _FCOST_ column expresses in units of preference the cost of the assignment. The SUM statement in the PRINT procedure is used to total the assignment cost.

 Chapter Contents Previous Next Top