Chapter Contents
Chapter Contents
The MDS Procedure

Getting Started

The simplest application of PROC MDS is to reconstruct a map from a table of distances between points on the map (Kruskal and Wish 1978, pp. 7-9). For example, the following DATA step reads a table of flying mileages between ten U.S. cities:

   data   city;
      title 'Analysis of Flying Mileages Between Ten U.S. Cities';
      input  (atlanta chicago denver houston losangeles
              miami newyork sanfran seattle washdc) (5.)
              @56 city $15.;
       0                                                  Atlanta
     587    0                                             Chicago
    1212  920    0                                        Denver
     701  940  879    0                                   Houston
    1936 1745  831 1374    0                              Los Angeles
     604 1188 1726  968 2339    0                         Miami
     748  713 1631 1420 2451 1092    0                    New York
    2139 1858  949 1645  347 2594 2571    0               San Francisco
    2182 1737 1021 1891  959 2734 2408  678    0          Seattle
     543  597 1494 1220 2300  923  205 2442 2329    0     Washington D.C.

Since the flying mileages are very good approximations to Euclidean distance, no transformation is needed to convert distances from the model to data. The analysis can therefore be done at the absolute level of measurement, as displayed in the following PROC MDS step (LEVEL=ABSOLUTE). An output data set containing the estimated configuration (coordinates on the map) is created with the OUT= option and then used to display the map using the %PLOTIT macro. The ID statement copies the names of the cities to the OUT= data set so that they can be used on the plot. The following statements produce Figure 40.1:

   proc mds data=city level=absolute out=out;
      id city;

By default, PROC MDS displays only the iteration history. In this example, only one iteration is required. The badness-of-fit criterion 0.001689 indicates that the data fit the model extremely well.

Analysis of Flying Mileages Between Ten U.S. Cities

Multidimensional Scaling: Data=WORK.CITY
Coef=IDENTITY Dimension=2 Formula=1 Fit=1

Gconverge=0.01 Maxiter=100 Over=1 Ridge=0.0001

Iteration Type Badness-
Change in
0 Initial 0.003273 . 0.8562
1 Lev-Mar 0.001689 0.001584 0.005128

Convergence criterion is satisfied.

Figure 40.1: Iteration History from PROC MDS

In order for the plot to represent the geometry of the configuration correctly, the axes must be scaled so that a given physical distance on one axis represents the same number of units as the same physical distance on the other axis. You can use the %PLOTIT macro to obtain such a scaling by specifying the VTOH= option. The VTOH= option indicates the ratio of the vertical distance between lines to the horizontal distance between characters; obtaining a suitable value may require some experimentation. The %PLOTIT macro can create graphical scatter plots with iteratively derived optimal label placement. See Appendix B, "Using the %PLOTIT Macro," for more information on the %PLOTIT macro. The following statements produce Figure 40.2:

   %plotit(data=out, datatype=mds, labelvar=city, 
           vtoh=1.75, labfont=swissb);

While PROC MDS can recover the relative positions of the cities, it cannot determine absolute location or orientation. In this case, north is toward the bottom of the plot.

mdsg2.gif (5321 bytes)

Figure 40.2: Plot of Estimated Configuration Using the %PLOTIT Macro

Chapter Contents
Chapter Contents

Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.