Converting an MPS/QPS-Format File: %MPS2SASD

As described in the section Overview: MPS-Format SAS Data Set, the MPS or QPS format is a standard file format for describing linear, integer, and quadratic programming problems. The MPS/QPS format is defined for plain text files, whereas in the SAS System it is more convenient to read data from SAS data sets. Therefore, a facility is required to convert MPS/QPS-format text files to MPS-format SAS data sets. The SAS macro %MPS2SASD serves this purpose.

In the MPS/QPS-format text file, a record refers to a single line of text that is divided into six fields. MPS/QPS files can be read and printed in both fixed and free format. In fixed MPS/QPS format, each field of a data record must occur in specific columns:

Field

Field 1

Field 2

Field 3

Field 4

Field 5

Field 6

Columns

2–3

5–12

15–22

25–36

40–47

50–61

In free format, fields of a record are separated by a space. Both fixed and free format have limitations. If users need to use row names or column names longer than 8 characters, then there is not enough space to hold them in fixed format. If users use a space as a part of a row name or column name, such as ROW NAME, then free-format MPS format interprets this symbol as two fields, ROW and NAME.

You can insert a comment record, denoted by an asterisk (*) in column 1, anywhere in an MPS/QPS file. Also, if a dollar sign ($) is the first character in field 3 or field 5 of any record, the information from that point to the end of the record is treated as a comment. All comments are ignored by the %MPS2SASD macro, described as follows.

%MPS2SASD Macro Parameters

%MPS2SASD (MPSFILE='infilename', OUTDATA=mpsdata, MAXLEN=n, FORMAT=FIXED/FREE);

MPSFILE='infilename'

specifies the path and name of the input MPS-format file. The input file is a plain text file, normally with either an .mps extension for linear programming problems or a .qps extension for quadratic programming problems. This parameter is required; there is no default value.

OUTDATA=mpsdata

specifies the name of the output MPS-format SAS data set. This parameter is optional; the default value is mpsdata.

MAXLEN=n

specifies length of the variables field2, field3, and field5 in the output MPS-format SAS data set. This parameter is optional; the default value is 8.

FORMAT=FIXED/FREE

specifies the format of the input MPS file. Valid values can be either FIXED or FREE. This parameter is optional; the default value is the one, if any, specified by the flat file and FIXED otherwise.