Not applicable
Posts: 0

# Optimal matching

Is there any way to do in IML the optimal matching (like in PROC ASSIGN) ?
SAS Super FREQ
Posts: 4,176

## Re: Optimal matching

Is there a way? Yes, but that doesn't mean it is the best or easiest way. If you previously used PROC ASSIGN (which is part of SAS/OR software), I suggest using PROC OPTMODEL, which provides a natural way to specify linear programming problems and is designed specifically for linear programming. For details and an example, see http://support.sas.com/kb/42/143.html
Not applicable
Posts: 0

## Re: Optimal matching

Thanks for the reply. The distance I am using for matching is the generalized Mahalanobis distance GMD (with some weights, http://sekhon.berkeley.edu/papers/GenMatch.pdf), which is easy to calculate in IML. The loop is:
2. create GMD matrix
3. do optimal match
4. check balance of covariates between matched cases and controls
5. if unbalanced then modify weights and goto 2.
I don't know how to do this matrix algebra in OPTMODEL.
SAS Super FREQ
Posts: 4,176

## Re: Optimal matching

Sounds like an interesting problem. Could you post a simple example (4 or 5 observations) and the code you have so far, so we can better understand the problem? I've never used PROC ASSIGN so it would be helpful to see an example.
Not applicable
Posts: 0

## Re: Optimal matching

The code gets truncated here, how can I send it to you ? Message was edited by: Zbig
Not applicable
Posts: 0

## Re: Optimal matching

OK, I know now how to do this algebra in OPTMODEL (this is the multiplicative product of several matrices only, I can code it). But the IML gives me the Genetic Algorithm framework, which is not available in OPTMODEL.
SAS Employee
Posts: 94

## Re: Optimal matching

What version of IML are you using? If you are using PROC IML, the latest version, 9.22, allows you to submit arbitrary SAS code from inside your IML program via a SUBMIT block. So, if you have this version of IML and you have SAS/OR, you should be able to use the fast and exact solvers in SAS/OR to solve the optimization problem exactly and quickly (provided you have a manageable problem size). If you have an earlier version of SAS/IML, if you can use IML Studio that also has a SUBMIT block for submitting SAS code. It is possible to apply genetic algorithms (GA) in PROC IML to try to solve the optimization problem, but the problem with GA in general is that you are not guaranteed convergence, and if you do get a solution you have no way to know if it is the true global optimum. Also for a problem of this type, the integer linear programming solvers available in SAS/OR will use a fraction of the time that a GA would use. So, do you have a version of IML with the SUBMIT block available? If so that would be far preferable to trying to use GA.
Not applicable
Posts: 0