We illustrate the use of the %MPS2SASD macro in this example, assuming the files example_fix.mps and example_free.mps are in your current SAS working directory.
The MPS2SASD macro function has one required parameter, MPSFILE= 'infilename', which specifies the path and name of the MPS/QPS-format
file. With this single parameter, the macro reads the file, converts the records, and saves the conversion to the default
MPS-format SAS data set MPSDATA
.
Running the following statements converts the fixed-format MPS file shown in Example 16.2 to the MPS-format SAS data set MPSDATA
:
%mps2sasd(mpsfile='example_fix.mps'); proc print data=mpsdata; run;
Output 16.4.1 displays the MPS-format SAS data set MPSDATA
.
Output 16.4.1: The MPS-Format SAS Data Set MPSDATA
Obs | field1 | field2 | field3 | field4 | field5 | field6 |
---|---|---|---|---|---|---|
1 | NAME | PROD_MIX | . | . | ||
2 | ROWS | . | . | |||
3 | N | PROFIT | . | . | ||
4 | L | STAMP | . | . | ||
5 | L | ASSEMB | . | . | ||
6 | L | FINISH | . | . | ||
7 | COLUMNS | . | . | |||
8 | DESK | STAMP | 3.0 | ASSEMB | 10 | |
9 | DESK | FINISH | 10.0 | PROFIT | -95 | |
10 | CHAIR | STAMP | 1.5 | ASSEMB | 6 | |
11 | CHAIR | FINISH | 8.0 | PROFIT | -41 | |
12 | CABINET | STAMP | 2.0 | ASSEMB | 8 | |
13 | CABINET | FINISH | 8.0 | PROFIT | -84 | |
14 | BOOKCSE | STAMP | 2.0 | ASSEMB | 7 | |
15 | BOOKCSE | FINISH | 7.0 | PROFIT | -76 | |
16 | RHS | . | . | |||
17 | TIME | STAMP | 800.0 | ASSEMB | 1200 | |
18 | TIME | FINISH | 800.0 | . | ||
19 | RANGES | . | . | |||
20 | T1 | ASSEMB | 900.0 | . | ||
21 | BOUNDS | . | . | |||
22 | UP | BND | CHAIR | 75.0 | . | |
23 | LO | BND | BOOKCSE | 50.0 | . | |
24 | ENDATA | . | . |
Running the following statement converts the free-format MPS file shown in Example 16.3 to the MPS-format SAS data set MPSDATA
:
%mps2sasd(mpsfile='example_free.mps');
The data set is identical to the one shown in Output 16.4.1.
In the following statement, when the free-format MPS file is converted, the length of the variables field2
, field3
, and field5
in the SAS data set MPSDATA
is explicitly set to 10 characters:
%mps2sasd(mpsfile='example_free.mps', maxlen=10, format=free);
If you want to save the converted data to a SAS data set other than the default data set MPSDATA
, you can use the parameter OUTDATA= mpsdata. The following statement reads data from the file example_fix.mps and writes
the converted data to the data set PRODMIX
:
%mps2sasd(mpsfile='example_fix.mps', outdata=PRODMIX);