The MPS-Format SAS Data Set |
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 14.2 to the MPS-format SAS data set MPSDATA:
%mps2sasd(mpsfile='example_fix.mps'); proc print data=mpsdata; run;
Output 14.4.1 displays the MPS-format SAS data set MPSDATA.
Output 14.4.1: The MPS-Format SAS Data Set MPSDATARunning the following statement converts the free-format MPS file shown in Example 14.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 14.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);
Copyright © 2008 by SAS Institute Inc., Cary, NC, USA. All rights reserved.