/***********************************************************************************
* This program is taken from the following book. If using please cite it as: *
* Emrouznejad, A. and W. Ho (2012). Applied Operations Research with SAS, *
* CRC Press: Taylor Francis Ltd, ISBN: 9781439841303. *
* For details please visit: http://www.sas-or.com. *
************************************************************************************/
* SAS macro for traveling salesman problem: solution to exercise 3.10.;
%let _title=’Traveling salesman problem: solution to exercise 3.10.’;
%let _data=’c:/sasor/Data3_10_exercise.txt’;
%let _travelP=city;
option nodate;
* The data handling macro;
%macro data;
* Import text tab delimited data file to SAS data file;
proc import
datafile=&_data
out=dtsp1
dbms=tab
replace;
getnames=yes;
run;
data dtsp(drop=&_travelP);
set dtsp1;
run;
%mend data;
* The model building macro;
%macro model;
proc ga Matrix1 = dtsp;
call SetEncoding (‘S6’);
call SetObj(‘TSP’,0,’distances’,Matrix1);
call SetCross(‘Order’);
call Initialize(‘DEFAULT’, 6);
call ContinueFor(85);
run;
%mend model;
* The report writing macro;
%macro report;
title &_title;
proc print;
run;
%mend report;
* A SAS macro for traveling salesman problem;
%macro ortsp;
%data;
%model;
%report;
%mend ortsp;
* SAS procedure for traveling salesman problem;
%ortsp;
/****************************************************************************
******************************END of the program*****************************
****************************************************************************/