Resources

Graphical Scatter Plots With Optimal Label Placement

 /****************************************************************/
 /*          S A S   S A M P L E   L I B R A R Y                 */
 /*                                                              */
 /*    NAME: PLOTITEX                                            */
 /*   TITLE: Graphical Scatter Plots With Optimal Label Placement*/
 /*          Illustrations of the PLOTIT macro.                  */
 /* PRODUCT: STAT                                                */
 /*  SYSTEM: ALL                                                 */
 /*    KEYS: graphs                                              */
 /*   PROCS:                                                     */
 /*    DATA:                                                     */
 /*                                                              */
 /* SUPPORT: saswfk                      UPDATE:  20Apr2004      */
 /*     REF: Experimental Design and Choice Modeling Macros,     */
 /*          Graphical Scatter Plots of Labeled Points,          */
 /*          Graphical Methods for Marketing Research            */
 /*          all available on the web at:                        */
 /* http://support.sas.com/techsup/tnote/tnote_stat.html#market  */
 /*    MISC: SAS/GRAPH software must be licensed.                */
 /*          The macro PLOTTIT is in the autocall library.       */
 /*                                                              */
 /*          If your site has installed the autocall libraries   */
 /*          supplied by SAS Institute and uses the standard     */
 /*          configuration of SAS software supplied by the       */
 /*          Institute, you need only to ensure that the SAS     */
 /*          system option MAUTOSOURCE is in effect to begin     */
 /*          using the autocall macros.  For more information    */
 /*          about autocall libraries, refer to SAS Macro        */
 /*          Language: Reference.                                */
 /*                                                              */
 /*          This sample shows macro usage.  See DISCRIM,        */
 /*          CANDISC, CORRESP, PRINQUAL, and TRANSREG samples    */
 /*          for more examples of macro usage.                   */
 /****************************************************************/

options gstyle;
ods listing style=statistical;
%let cback = cxFFFFFF;

****************************************************************
*   Title: Multidimensional Preference Analysis Of Cars Data   *
****************************************************************;

title 'Preference Ratings for Automobiles Manufactured in 1980';

data carpref;
   length model $ 20;
   input Make $ 1-10 Model $ 12-22 @25 (Judge1-Judge25) (1.)
         MPG Reliable Ride;
   label mpg      = 'Miles per gallon'
         reliable = 'Reliability'
         ride     = 'Ride';
   datalines;
Cadillac   Eldorado     8007990491240508971093809 3 2 4
Chevrolet  Chevette     0051200423451043003515698 5 3 2
Chevrolet  Citation     4053305814161643544747795 4 1 5
Chevrolet  Malibu       6027400723121345545668658 3 3 4
Ford       Fairmont     2024006715021443530648655 3 3 4
Ford       Mustang      5007197705021101850657555 3 2 2
Ford       Pinto        0021000303030201500514078 4 1 1
Honda      Accord       5956897609699952998975078 5 5 3
Honda      Civic        4836709507488852567765075 5 5 3
Lincoln    Continental  7008990592230409962091909 2 4 5
Plymouth   Gran Fury    7006000434101107333458708 2 1 5
Plymouth   Horizon      3005005635461302444675655 4 3 3
Plymouth   Volare       4005003614021602754476555 2 1 3
Pontiac    Firebird     0107895613201206958265907 1 1 5
Volkswagen Dasher       4858696508877795377895000 5 3 4
Volkswagen Rabbit       4858509709695795487885000 5 4 3
Volvo      DL           9989998909999987989919000 4 5 5
;

proc prinqual data=carpref out=results n=2 replace mdpref;
   id model;
   transform ide(judge1-judge25);
   title2 'Multidimensional Preference (MDPREF) Analysis';
run;

data results;
   set results;
   if _type_ = 'CORR' then model = substr(model,6);
run;

%plotit(data=results, datatype=mdpref 2.5)

%plotit(data=results, datatype=mdpref2 2.5)

****************************************************************
*   Title: Preference Mapping Of The Cars Data Set             *
****************************************************************;

*---Compute Coordinates for a 2-Dimensional Scatterplot of Cars---;
proc prinqual data=carpref out=presults(drop=judge1-judge25) n=2
              replace standard scores;
   id model mpg reliable ride;
   transform ide(judge1-judge25);
   title2 'Multidimensional Preference (MDPREF) Analysis';
   title3 'Optimal Monotonic Transformation of Preference Data';
run;

*---Compute Endpoints for MPG, Reliability, Ride Vectors---;
proc transreg data=presults;
   model ide(mpg reliable ride)=identity(prin1 prin2);
   output tstandard=center coefficients replace out=tresult1;
   id model;
   title2 'Preference Mapping (PREFMAP) Analysis';
run;

%plotit(data=tresult1, datatype=vector 2.5)

*---Compute Ideal Points for MPG and Reliability---;
proc transreg data=presults;
   model identity(mpg reliable ride)=point(prin1 prin2);
   output tstandard=center coordinates replace out=tresult1;
   id model;
   title2 'Preference Mapping (PREFMAP) Analysis';
run;

%plotit(data=tresult1, datatype=ideal, antiidea=1)

****************************************************************
*   Title: Preference Ratings For Automobiles Manufactured In  *
*     Ref: Proc Prinqual, Example 1.                           *
****************************************************************;

*---Principal Component Analysis of the Original Data---;
proc factor data=carpref nfactors=2 plot=scree;
   var judge1-judge25;
   title2 'Principal Components of Original Data';
run;

proc prinqual data=carpref out=results n=2 replace mdpref;
   id model;
   transform monotone(judge1-judge25);
   title2 'Multidimensional Preference (MDPREF) Analysis';
   title3 'Optimal Monotonic Transformation of Preference Data';
run;

*---Final Principal Component Analysis---;
proc factor data=results nfactors=2 plot=scree;
   var judge1-judge25;
   where _type_='SCORE';
   title3 'Principal Components of Monotonically Transformed Data';
run;

*---Plot the Results---;
%plotit(data=results, datatype=mdpref 1.5)

****************************************************************
*   Title: Preference Ratings For 1980 Automobiles             *
*     Ref: Proc Transreg, Example 6                            *
****************************************************************;

*---Compute Coordinates for a 2-Dimensional Scatterplot of Cars---;
proc prinqual data=carpref out=presults(drop=judge1-judge25) n=2
              replace standard scores;
   id model mpg reliable ride;
   transform monotone(judge1-judge25);
   title2 'Multidimensional Preference (MDPREF) Analysis';
   title3 'Optimal Monotonic Transformation of Preference Data';
run;

*---Compute Endpoints for MPG and Reliability Vectors---;
proc transreg data=presults;
   model untie(mpg reliable)=identity(prin1 prin2);
   output tstandard=center coefficients replace out=tresult1;
   id model;
   title2 'Preference Mapping (PREFMAP) Analysis';
run;

*---Compute Ride Ideal Point Coordinates---;
proc transreg data=presults;
   model untie(ride)=point(prin1 prin2);
   output tstandard=center coordinates replace noscores out=tresult2;
   id model;
   title2 'Preference Mapping (PREFMAP) Analysis';
run;

*---Create Plotting Data Set---;
data results;
   set tresult1 tresult2;
run;

%plotit(data=results, datatype=vector ideal,
        radii=%str(1.5,3), antiidea=1)

****************************************************************
*   Title: Canonical Discriminant Analyses Of Cars Data Set    *
****************************************************************;

title 'Canonical Discriminant Analysis';

data cancars;
   input Origin $ 1-8 Make $ 10-19 Model $ 21-36
         (Mpg Reliability Acceleration Braking Handling Ride
          Visibility Comfort Quiet Cargo) (1.);
   datalines;
GMC      Buick      Century         3334444544
GMC      Buick      Electra         2434453555
GMC      Buick      Lesabre         2354353545
GMC      Buick      Regal           3244443424
GMC      Buick      Riviera         2354553543
GMC      Buick      Skyhawk         3232423224
GMC      Buick      Skylark         4145555422
GMC      Chevrolet  Camaro          2254541241
GMC      Chevrolet  Caprice Classic 2445353555
GMC      Chevrolet  Chevette        5335425223
GMC      Chevrolet  Citation        4155555525
GMC      Chevrolet  Corvette        2153542242
GMC      Chevrolet  Malibu          3333444544
GMC      Chevrolet  Monte Carlo     3253353544
GMC      Chevrolet  Monza           2142233114
Chrysler Dodge      Aspen           2143333424
Chrysler Dodge      Colt Hatchback  5544445434
Chrysler Dodge      Diplomat        2153343434
Chrysler Dodge      Mirada          2143432434
Chrysler Dodge      Omni 024        4345535225
Chrysler Dodge      St Regis        1154353545
Ford     Ford       Fairmont        3324345434
Ford     Ford       Fiesta          5445344414
Ford     Ford       Granada         2233233233
Ford     Ford       LTD             3354354555
Ford     Ford       Mustang         3244323222
Ford     Ford       Pinto           4134313222
Ford     Ford       Thunderbird     2354344444
Ford     Mercury    Bobcat          4134313212
Ford     Mercury    Capri           3154322222
Ford     Mercury    Cougar XR7      2454444444
Ford     Mercury    Marquis         3354354555
Ford     Mercury    Monarch         2353232232
Ford     Mercury    Zephyr          3124345434
GMC      Oldsmobile Cutlass         3443444544
GMC      Oldsmobile Delta 88        2435353555
GMC      Oldsmobile 98              2445353555
GMC      Oldsmobile Omega           4155555522
GMC      Oldsmobile Starfire        2133522154
GMC      Oldsmobile Toronado        3323443544
Chrysler Plymouth   Champ           5544445434
Chrysler Plymouth   Gran Fury       2134353535
Chrysler Plymouth   Horizon         4345535235
Chrysler Plymouth   Volare          2153333424
GMC      Pontiac    Bonneville      2345353555
GMC      Pontiac    Firebird        1153551231
GMC      Pontiac    Grand Prix      3224432434
GMC      Pontiac    Lemans          3333444544
GMC      Pontiac    Phoenix         4155554415
GMC      Pontiac    Sunbird         3134533234
;

proc candisc data=cancars out=outcan;
   class origin;
   var acceleration handling ride visibility cargo;
run;

title2 'Color Groups by Origin';
%plotit(data=outcan, plotvars=can2 can1, typevar=origin, labelvar=model)

title2 'Color Groups by Make';
%plotit(data=outcan, plotvars=can2 can1, typevar=make, labelvar=model)

%macro doit;
   %let varlist = mpg reliability comfort;
   %let i = 1;
   %let avar = %scan(&varlist,1,%str( ));
   %do %while(&avar ne );
      title2 "Blue to Red is Low to High on &avar";
      %plotit(data=outcan,plotvars=can2 can1,
              labelvar=model,paint=&avar)
      %let i = %eval(&i + 1);
      %let avar = %scan(&varlist,&i,%str( ));
      %end;
%mend;

%doit;

****************************************************************
*   Title: Car Owners And Car Origin                           *
*     Ref: Proc Corresp, Example 1 and 2.                      *
****************************************************************;

title 'Car Owners and Car Origin';

proc format;
   value origin  1 = 'American' 2 = 'Japanese' 3 = 'European';
   value size    1 = 'Small'    2 = 'Medium'   3 = 'Large';
   value type    1 = 'Family'   2 = 'Sporty'   3 = 'Work';
   value home    1 = 'Own'      2 = 'Rent';
   value sex     1 = 'Male'     2 = 'Female';
   value income  1 = '1 Income' 2 = '2 Incomes';
   value marital 1 = 'Single with Kids' 2 = 'Married with Kids'
                 3 = 'Single'           4 = 'Married';
run;

data cars;
   missing a;
   /* Read Numeric Variables */
   input (origin size type home income marital kids sex) (1.) @@;
   /* Check for End of Line */
   if n(of origin -- sex) eq 0 then do;
      input;
      return;
   end;
   marital = 2 * (kids ne 0) + marital;
   format origin origin. size size. type type. home home.
          sex sex. income income. marital marital.;
   return;
   datalines;
131112212121110121112201131211011211221122112121131122123211222212212201
121122023121221232211101122122022121110122112102131112211121110112311101
211112113211223121122202221122111311123131211102321122223221220221221101
122122022121220211212201221122021122110132112202213112111331226122221101
1212110231AA220232112212113112112121220212212202112111022222110212121221
211211012211222212211101313112113121220121112212121112212211222221112211
221111011112220122212201131211013121220113112222131112012131110221112211
121112212211121121112201321122311311221113112212213211013121220221221101
133211011212220233311102213111023211122121312222212212111111222121112211
133112011212112212112212212222022131222222121101111122022211220113112212
211112012232220121221102213211011131220121212201211122112331220233312202
222122012111220212112201221122112212220222212211311122012111110112212212
112222011131112221212202322211021222110121221101333211012232110132212101
223222013111220112211101211211022112110212211102221122021111220112111211
111122022121110113311122322111122221210222211101212122021211221232112202
1331110113112211213222012131221211112212221122021331220212121112121.2212
121122.22121210233112212222121011311122121211102211122112121110121212101
311212022231221112112211211211312221221213112212221122022222110131212202
213122211311221212112222113122221221220213111221121211221211221221221102
131122211211220221222101223112012111221212111102223122111311222121111102
2121110121112202133122222311122121312212112.2101312122012111122112112202
111212023121110111112221212111012211220221321101221211122121220112111112
212211022111110122221101121112112122110122122232221122212211221212112202
213122112211110212121201113211012221110232111102212211012112220121212202
221112011211220121221101211211022211221112121101111112212121221111221201
211122122122111212112221111122312132110113121101121122222111220222121102
221211012122110221221102312111012122220121121101121122221111222212221102
212122021222120113112202121122212121110113111101123112212111220113111101
221112211321210131212211121211011222110122112222123122023121223112212202
311211012131110131221102112211021131220213122201222111022121221221312202
131.22523221110122212221131112412211220221121112131222022122220122122201
212111011311220221312202221122123221210121222202223122121211221221111112
211111121211221221212201113122122131220222112222211122011311110112312211
211222013221220121211211312122122221220122112201111222011211110122311112
312111021231220122121101211112112.22110222112212121122122211110121112101
121211013211222121112222321112112112110121321101113111012221220121312201
213211012212220221211101321122121111220221121101122211021122110213112212
212122011211122131221101121211022212220212121101
;

*---Simple Correspondence Analysis---;
proc corresp all data=cars outc=coor;
   tables marital, origin;
run;

%plotit(data=coor, datatype=corresp)

*---Multiple Correspondence Analysis---;
proc corresp mca observed data=cars outc=coor;
   tables origin size type income home marital sex;
run;

%plotit(data=coor, datatype=mca)

****************************************************************
*   Title: Multidimensional Scaling Of Beverages Data Set      *
****************************************************************;

title 'Multidimensional Scaling of Beverages';

data dissim;
   do i = 1 to 3; drop i;
      input   (Coke OrangeSoda LemonKoolAid Milk HotTea IceTea
               HotCoffee IceCoffee Water AppleJuice GrapeJuice
               Rum Beer Wine Scotch Postum SevenUp DrPepper
               Lemonade PepsiCola OrangeCrush V8Juice) (1.) @@;
      output;
   end;
   input;
   datalines;
.8...5...4...8...2....8.3...8...5...9...2....3.9...6...9...8...5..
..9.9...7...9...8...8....9.6...6...8...4...75...6.5...6...9...4...
.8...5.6...8...2...8....6...6.5...5...8...8....7...5.8...8...8...8
4...6...8.6...9...5....5...6...6.9...8...5....9...8...9.5...9...9.
...9...5...5.7...9...98...8...8...7.6...6....9...9...9...6.8...9..
..8...2...8...8.6...8....8...8...9...6.4...82...4...8...9...4.7...
.2...4...5...6...7.7....5...8...5...9...7.7....8...8...9...8...7.8
....7...8...9...8...8....9...7...9...5...2......7...5...9...3...1.
.....6...4...8...5...49.....7...7...9...6....7.....5...8.......4..
..6.....3...9...5...4....7.....7...8...7...77...5.....9...7...7...
.5...3.....9...5...5....4...7.....9...6...3....7...9.....3...6...5
9...8...9.....1...8....9...9...9.....9...9....8...8...3.....7...7.
...9...7...1.....9...85.......5...9.....8....3...5...6...7.....6..
..5...7...6...9.....6....6...7...8...8.....52...4...5...9...6.....
.1...4...3...7...6......4...7...5...8...5......8...4...5...4...1..
....8...5...4...4...1......5...3...6...6...68.....8...8...9...8...
.8.....7...8...7...7....5.....4...5...5...5....8.....9...9...7...8
4...7.....8...7...8....5...4.....5...6...6....3...9.....5...5...3.
...8...8.....3...5...75...8...5.....5...6....4...5...5.....9...4..
..6...9...3.....7...7....9...7...5.....5...84...7...6...9.....8...
.4...5...5...7.....4....6...7...5...5.....5....8...8...6...8.....8
1...7...6...4...4......1...5...3...7...5......6...8...7...8...8...
.5...4...7...6...5....5.3...7...6...8...3....3.9...7...8...7...5..
..9.9...7...8...8...8....9.2...6...7...6...84...2.7...5...8...6...
.7...7.2...7...2...7....7...2.7...7...7...7....7...7.7...7...6...7
7...6...7.3...7...5....6...5...3.7...7...6....8...7...7.4...6...7.
...8...7...4.6...6...76...7...7...6.6...7....8...8...7...6.8...7..
..7...2...7...8.6...7....8...7...6...6.6...85...6...6...6...6.7...
.3...6...5...7...7.6....5...7...6...7...6.5....8...7...7...7...5.6
....8...7...7...8...6...6...7...6...8...7......8...5...9...6...6..
6...4...2...8...5...3..8...7...8...8...8...8..4...4...6...9...5...
...7...4...8...3...6..7...4...4...7...5...6..5...4...6...6...6...7
..2...4...5...9...3......8...6...7...6...6..6...6...5...6...7...6.
.9...8...7...6...7...9..8...7...6...7...7......8...6...6...8...7..
8...9...9...7...8...9..6...3...6...8...5...7..5...5...7...8...5...
...8...6...7...5...3..7...5...3...7...5...3..6...6...6...7...3...8
..3...6...6...9...3......8...7...9...7...8......8...7...7...3...3.
.....5...3...4...4...8......5...3...8...2..........8...8...8...9..
8.......6...5...7...7..5.......6...6...6...8..5.......9...8...8...
...8.......4...2...5..7...6.......7...6...7..3...6.......2...5...6
..3...9.......8...4......8...4.......6...4..7...5...7.......6...7.
.4...6...2.......4...9..8...8...8.......4......8...2...6.......7..
3...7...6...6.......2..4...6...5...4.......7..2...8...4...4.......
...9...5...4...7......3...7...7...7...2......8...8...6...9...7....
....7...5...3...2...3......5...3...4...3...4......6...2...8...1...
.......6...8...6...6..7.......2...4...3...5..5.......5...5...4...3
..6.......6...8...6......6.......8...2...6..5...2.......3...3...4.
.3...5.......2...2...3..2...6.......8...3......8...8.......7...5..
3...4...3.......4...3..4...5...2.......4...3..8...8...8.......7...
...6...2...7.......7..2...3...3...4.......4..3...4...2...4.......4
..1...6...3...7..........6...6...5...7......3...5...4...3...4.....
.4...3...3...3...4......7...7...6...6...7......9...7...7...7...8..
7...8...6...7...6...6..9...7...7...8...8...9..8...5...7...7...7...
...7...7...7...6...8..7...5...8...7...7...7..7...7...7...7...6...8
..6...8...7...6...7......7...7...7...6...7..6...7...7...9...7...6.
.7...7...7...6...6...8..7...7...9...7...7......8...7...6...7...7..
6...7...6...7...7...7..7...6...6...7...6...8..6...7...7...7...6...
...8...6...6...6...7..7...7...7...7...6...6..8...8...7...7...7...7
..6...7...6...7...6......9...8...8...8...7...6...3...6...5........
6.2...8...7...3...3....2.9...8...2...9...5....9.8...7...9...8...9.
...8.2...4...5...3...93...2.4...5...3...3....8...4.2...9...7...5..
..8...2.8...8...6...6....7...8.2...2...9....6...4...2.3...2...2...
.7...5...3.8...9...3....2...9...8.5...3...4....9...8...5.6...9...9
5...5...2...6.4...2....3...3...2...4.9...6....9...7...9...9.9...9.
...8...6...3...9.6...9....3...9...9...6.5....3...3...2...2...5.4..
..5...5...3...6...4.5....9...6...4...9...5.9....9.......9...9...9.
....5...9...9...9...9......9.......9...8...9......8...8...9...2...
.......9...9...9...9..5.......7...9...8...9..9.......9...8...9...9
..8.......9...9...9......9.......9...8...8..9...7.......9...8...9.
.....9.......7...8...9..8...9.......6...7......9...9.......9...9..
9...9...9.......9...9..9...8...7.......8...9..9...9...6.......9...
...9...8...9.......9..9...8...8...9.......6..8...9...8...8.......8
..2...9...7...9..........9...8...9...9......9...9...9...9...6.....
.9...9...9...9...8......9...9...9...9...9......9...9...9...9...9..
9...9...9...9...6...6..9...9...9...9...9...9..9...8...9...9...9...
...9...9...9...8...9..9...8...9...9...9...9..9...9...9...9...9...9
..9...9...9...9...9......9...9...9...9...9..9...9...9...9...9...8.
.9...9...9...8...9...9..9...9...9...8...9......9...9...8...9...9..
9...9...9...8...9...9..9...8...9...9...9...9..6...9...9...9...6...
...9...9...9...9...8..9...9...9...9...6...7..9...9...9...9...8...9
..6...9...8...9...7......9...9...9...9...9.....9...9...7...7...4..
....9...9...9...6...1......9...3...4...5...89.....9...9...9...9...
.9.....5...5...5...8....9.....9...7...9...8....9.....9...9...8...9
9...5.....9...3...9....9...9.....9...9...9....3...9.....9...5...3.
...9...9.....3...4...87...5...9.....6...5....9...7...9.....8...9..
..4...9...3.....7...5....9...3...6.....9...97...5...9...8.....9...
.6...9...5...7.....9....5...8...4...9.....9....9...9...5...9.....9
4...8...9...9...9......1...8...3...5...9......8...9...8...9...9...
..8...7...7...9...8......9...9...9...8...8..8...8...7...8...7...8.
.9...8...9...9...9...9..8...7...9...9...9......8...9...9...7...9..
7...7...9...9...9...9..9...9...8...9...7...8..7...9...8...9...6...
...9...8...8...7...8..7...9...8...9...7...8..9...9...8...9...9...9
..8...9...9...9...8......9...9...9...9...9..9...9...9...9...9...9.
.8...7...7...9...7...8..7...9...7...9...6......9...7...9...7...5..
8...9...6...8...6...7..8...9...8...9...5...8..8...9...8...9...7...
...9...8...9...8...8......7...4...5...3...2......4...3...4...2...7
......7...3...7...4..........6...8...4...7..7.......4...6...6...5.
.4.......4...5...5...7..7.......8...6...6......6.......5...3...6..
4...4.......4...4...4..3...4.......3...4...4..3...8.......7...2...
...8...5.......6...4..5...6...4.......4...6..4...5...3.......6...7
..7...6...7.......6......4...3...6.......6..3...6...4...4.......2.
.2...5...4...6.......4..4...6...2...6..........7...6...4...6......
2...5...4...6...2......7...7...4...7...4.......9...4...8...6...1..
....9...7...8...6...2......7...5...9...8...89.....9...9...9...9...
.9.....7...7...4...8....7.....4...9...6...7....9.....9...9...9...8
4...7.....6...9...9....7...4.....9...7...9....5...9.....9...5...5.
...9...6.....7...3...58...7...9.....3...7....8...9...9.....9...9..
..9...9...7.....9...9....9...9...3.....9...96...4...7...9.....7...
.6...6...5...9.....5....8...9...3...9.....6....9...9...7...7.....7
1...8...9...9...5......2...7...5...9...6......8...8...5...9...7...
..4...3...4...6...3......7...7...6...7...1..4...7...3...4...1...1.
.7...7...6...7...9...7..7...3...6...6...5......7...4...7...3...3..
3...3...7...6...7...7..7...4...7...5...6...8..3...7...6...7...3...
...6...7...7...6...7..4...6...6...7...4...5..6...7...7...3...6...8
..4...6...7...4...7......7...5...3...8...2..6...6...7...4...7...7.
.7...3...6...8...7...7..1...7...4...7...3......9...6...6...7...3..
3...5...3...7...3...2..1...3...7...2...3...8..1...7...5...7...2...
...7...8...8...7...8....6...8...4...7...4......9...9...7...8...4..
6...7...4...6...3...2..9...8...5...8...8...8..7...2...8...8...6...
...8...3...5...3...6..8...2...6...7...8...9..9...3...8...7...3...7
..4...6...9...8...2......5...8...4...8...3..4...8...9...7...8...4.
.7...5...4...3...8...9..6...7...7...7...4......8...7...3...8...7..
7...8...8...7...8...9..8...3...8...8...7...9..3...8...8...8...2...
...8...3...8...7...4..4...6...2...4...2...4..4...6...3...7...4...7
..2...9...4...9...4......8...7...9...9...7...3...4...4...8...1....
3.2...7...3...9...1....2.5...4...8...7...1....5.7...3...8...8...9.
...7.5...4...8...6...44...5.5...3...8...1....7...5.5...8...3...7..
..4...5.8...6...4...2....3...8.7...8...5...54...4...7.1...8...3...
.3...3...1.9...6...5....8...8...9.2...5...8....8...6...2.2...7...8
8...8...8...2.2...6....9...8...8...2.9...7....7...3...6...9.7...6.
...8...4...5...7.1...71...6...5...7...1.3....1...1...3...6...3.2..
..1...7...5...7...2.2....9...2...8...6...2.7....4...5...8...7...7.
...9...7...8...7...1......9...6...9...2...1......4...4...6...6...8
9.....9...9...9...9....9.....6...8...2...9....4.....5...9...7...4.
...9.....9...9...9...97...6.....9...9...9....6...5.....9...8...7..
..4...9.....9...4...1....9...9.....2...4...88...8...9.....1...9...
.9...9...9.....9...7....6...9...2.....6...5....9...9...1.....9...9
7...2...8...9.....9....2...7...4...6.....5....6...9...4...9.....3.
...9...9...9...9.....81...9...7...7...5......1...4...1...5...3....
..8...9...8...9...8.......8...5...3...3...3......7...3...5...3...6
......8...3...7...2..........6...9...7...8..8.......6...6...7...7.
.7.......6...7...6...8..8.......8...8...6......6.......8...3...7..
5...6.......5...3...3..3...6.......2...4...5..3...8.......7...3...
...9...8.......9...3..3...6...5.......4...4..5...7...2.......4...5
..7...8...7.......6......7...3...9.......8..3...7...3...4.......3.
.3...6...4...4.......8..2...6...3...6..........8...7...3...8......
3...7...3...4...3......6...8...5...5...8......5...7...6...7...4...
...9...4...6...6...3..5...6...5...5...2...3..9...7...8...8...9...9
..6...1...7...7...5......7...3...5...4...3..7...1...7...7...7...7.
.4...3...6...7...5...8..5...7...6...7...4......8...6...7...7...6..
6...7...6...7...5...4..6...5...7...3...6...8..5...7...7...6...7...
...8...7...3...8...7..7...7...7...6...7...7..6...4...7...8...7...7
..2...7...5...7...3......9...5...6...7...3..4...5...4...7...3...3.
.3...3...6...7...3...8..3...7...4...7...3......9...8...8...7...8..
..7...8...7...4...6......9...8...8...7...6..7...8...4...5...3...2.
.9...7...8...8...9...4..8...2...8...8...7......7...3...7...3...6..
8...2...4...8...9...8..8...3...8...7...6...8..4...4...4...6...3...
...8...8...7...9...4..7...8...4...8...8...4..8...7...7...3...5...9
..5...8...8...4...7......8...7...3...6...7..4...8...6...4...7...9.
.7...3...9...6...8...8..3...9...8...7...5......9...6...5...8...1..
6...7...3...7...5...4..6...6...4...7...1...8..2...8...4...9...4...
...4...8...9...8...8.....9...7...7...6...1......7...5...6...4...1.
.....4...3...5...3...59.....7...8...9...8....7.....5...6...4...6..
..4.....5...5...4...5....7.....7...7...7...77...5.....7...8...7...
.5...5.....5...7...5....3...7.....4...3...3....8...7.....4...3...5
7...6...5.....2...7....6...5...4.....8...5....5...7...4.....4...5.
...9...8...2.....6...76...4...7...8.....8....4...4...3...4.....5..
..3...7...3...6.....3....8...7...7...8.....41...6...5...5...5.....
.1...5...3...5...3......5...7...5...7...4....8...6...5...3...6....
8.3...8...2...8...2....3.6...7...7...8...4....6.6...6...9...3...5.
...6.3...6...6...5...46...3.7...4...8...2....8...7.2...3...1...8..
..7...2.8...8...8...8....6...8.6...8...6...55...6...6.2...9...2...
.2...4...2.8...8...5....7...3...8.4...8...8....9...8...4.7...9...8
3...6...8...7.6...7....8...8...9...6.3...8....8...1...8...3.8...8.
...3...8...8...8.4...66...5...6...9...4.4....2...2...2...7...4.7..
..4...8...5...8...7.4....5...8...8...8...4.5....4...5...8...6...5.
.5...4...4...4...1....5.3...6...1...8...2....3.7...2...5...6...4..
..7.8...7...8...8...8....8.2...5...7...3...74...2.6...2...6...1...
.6...6.4...7...2...4....2...4.2...5...4...4....7...2.3...4...3...9
4...5...3.1...6...1....1...2...1.8...6...3....5...7...8.7...7...5.
...8...5...7.4...6...74...7...4...4.5...5....8...6...6...5.8...6..
..6...2...6...8.9...6....8...4...7...9.4...81...3...3...6...4.4...
.2...1...1...5...4.4....4...4...3...6...4.3....8...4...5...6...3.7
....7...9...7...8...7..8...5...7...4...5....8.5...7...4...6...4...
.5.6...5...7...4...4....6.3...8...8...4...6....3.2...7...9...4...4
5...2.6...5...7...3....7...6.2...........4....5...2.2...5...7...4.
...8...2.3...8...9...47...7...3.2...8...3....4...5...2.3...5...3..
..7.......3.2...6...9....8...5...2.2...6...64...9...8...2.3...7...
.6...7...8...3.4...7....4.......5...4.8...5....4...7...6...8.6...6
5...4...9...6...6.3....4...3...3...7...3.3....4...4...3...7...3.5.
...6...4...9...5...5.5....4...4...6...6...5.....8...5...4...2...2.
.....4...3...4...2...3......8...2...9...1..........3...7...5...4..
8.......5...6...6...5..4.......4...4...3...3..8.......9...8...8...
...3.......5...2...3..5...5.......4...5...4..3...4.......3...3...2
..2...9.......8...2......7...5.......9...5..4...6...4.......4...3.
.4...4...3.......5...4..9...8...8.......5......5...2...9.......9..
2...6...5...4.......2..2...3...3...5.......4..1...8...2...5.......
...4...3...5...9......2...5...4...3...2......3...3...2...4...4....
.4...6...7...7...3....4.3...9...2...8...5....3.6...5...6...7...3..
..6.4...4...6...7...7....4.2...8...7...7...96...2.5...6...5...4...
.9...5.2...7...1...9....5...2.3...5...7...4....4...3.7...3...4...9
7...8...7.3...6...4....2...6...3.7...4...2....6...7...7.6...6...6.
...6...5...6.6...6...57...7...3...6.6...5....8...5...6...6.6...6..
..7...1...4...6.4...6....7...7...6...4.5...63...7...4...6...5.5...
.5...4...4...5...5.4....3...9...2...6...4.4....7...4...6...6...4.8
....9...9...5...6...8..9...4...6...8...2....9.4...9...4...9...2...
.4.9...7...8...8...5....9.8...6...9...9...9....8.2...7...7...7...9
4...2.6...4...9...3....9...6.2...9...2...8....7...2.7...7...8...8.
...6...7.4...8...8...76...7...4.5...7...4....4...4...5.7...8...7..
..8...9...7.5...9...8....9...7...5.5...7...88...7...8...5.8...8...
.9...9...7...8.9...9....8...2...8...9.9...9....9...8...9...9.6...9
2...7...8...7...6.5....2...3...4...8...5.8....5...8...7...9...8.6.
...9...8...8...9...6.7....9...7...8...9...7....7...3...3...8...1..
....9...9...7...3...2......4...3...7...5...77.....9...8...9...8...
.9.....9...7...3...6....4.....2...4...4...7....9.....9...9...9...8
3...9.....7...9...4....9...2.....7...4...5....3...9.....3...3...3.
...8...7.....6...8...33...7...7.....7...3....7...4...3.....9...4..
..7...9...6.....8...8....9...9...7.....9...98...3...4...9.....8...
.3...4...3...8.....2....5...9...8...9.....2....8...4...3...8.....3
1...6...5...4...2......2...7...3...8...2......7...8...3...9...3...
....9...4...8...4...4......8...3...9...8...8......9...7...9...3...
.......8...9...6...7..9.......4...9...8...9..8.......7...9...5...7
..9.......9...7...9......8.......7...4...5..4...4.......6...5...7.
.3...7.......3...3...5..7...9.......9...5......9...7.......7...8..
8...9...6.......7...9..9...9...3.......9...8..9...7...9.......8...
...6...4...7.......9..4...8...5...7.......7..8...5...3...9.......8
..3...9...5...8..........7...5...8...9......4...9...7...9...7.....
.8...7...5...8...8.....6...3...6.......1....6.2...9...4...8...1...
.2.5...4...6.......3....5.3...9.......9...7....3.4...9.......9...9
3...4.5...8.......4....9...5.5................4...5.5...........4.
...9...5.3.......3...96...9...3.2.......3....4...8...2.........4..
..6...............................................................
.8.............................................9.............2...8
1...9...3.......2.2....1...4...3.......2.2....3.......4.......2.3.
...7...4...........3.4....9...9.......8...4..5...5...8...7...2....
5.5...8...5.......4....5.9...8.......9...7....9.7...9...9...7...9.
...7.6...8...7...8...95...6.7...7.......6....8...7.6.......6...8..
..8...6.9...9...7...7....9...9.7...9...5...78...8...7.5.......6...
.5...7...5.....9...7...........................9...9.....4...7...8
7...7...9...4.....7..................9........9...6...9...9.8...9.
...7...7.......8.2...82...8...5...7...2.6....4...6...6...7...6.7..
..7...8...7.......7.4....9...7.......9...4.8....9...7...8...8...8.
.8...6...7...7...3....8.6...9...7...8...3....6.9...7...8...7...4..
..9.8...7...9...8...7....8.5...7...8...4...46...5.8...6...7...2...
.9...8.9...7...4...7....7...9.5...7...7...4....7...5.6...6...7...3
7...7...6.3...8...7....7...6...3.9...8...6....8...7...9.7...8...8.
...9...7...7.6...6...97...8...6...6.7...7....8...7...8...7.8...8..
..7...4...8...8.7...9....8...7...8...7.7...73...4...7...6...7.6...
.3...2...7...7...6.7....4...7...6...8...7.7....7...4...8...9...7.8
....4...3...9...7...8..8...8...7...8...4....8.7...8...5...9.......
.7.9...7...9...9...8....9.9...7...9...9...9....9.5...8...9.......9
8...5.9...8...9...6....8...9.5...9...4...8....7...5.8...8...9...8.
...7...8.9...8...9...97...8...9.5...9...4....5...8...5.9...8...8..
..9...9...9.9...9...9....9...8...9.7...8...98...9...8...7.9...8...
.9...9...9...9.9...9....9...4...8...9.9...8....9...9...9...9.8...9
4.......9...8...8.7........6...4...8...7.8....8...8...8...9...8.8.
...9...8...9...8...8.9....9...9...9...9...9....9...........4...9..
....9...9.......5...1......4...6.......5...69.....9...8...9...9...
.9.....8...........9....4.....9.......9...5....9..................
....8.....9............9...9.....9.......9....6.............6...5.
...8...9.....9...9...7........9.....2......................9......
..........9.....9........9.......2..........4...........9.....9...
.5...9...6...9.....9....5.......9.........8....9...........9.....7
9...9...9.......9......1...5...5.......8......6.......7.......7...
.6...6...8...8...4....6.7...9...6...8...4....7.9...9...9...9...7..
..9.7...6...7...9...9....7.4...7...8...7...96...4.8...7...8...5...
.9...8.5...8...4...8....9...5.5...9...9...9....6...5.5...6...6...9
8...7...5.4...7...6....6...7...4.9...9...6....9...8...9.6...8...9.
...7...9...6.6...7...98...8...6...6.6...7....8...8...7...6.9...8..
..9...4...9...9.9...9....9...9...8...9.8...94...7...6...7...8.7...
.4...5...6...7...7.6....7...8...6...8...6.6....9...9...9...9...6.9
....9...9...9...9...9....8...8...6.......1......5...7...8...4...1.
.....6...2...7...2...68.....9...9...9...9....5.....9...9.......9..
..6.....4...9...7...3....9.....9...9...9...98...9.....8...8...9...
.7...4.....7.......6....2...9.....5...2...3....9...8.....4...3...9
6...9...7.....1...7....8...9...5.........9....7...9...4.....8...3.
...9...8...1.....8...9.......................4...7...2...8.....8..
..2...9...3...8.....6....9...9...7.........91...9...6...9...8.....
.1...3...3...3...6......6...9...9...9...9....3...6...3...3...1....
3.4...9...2...4...3....4.8...7...2...9...2....8.5...4...9...6...7.
...5.2...5...8...5...66...2.6...7...7...4....9...6.2...8...1...7..
..7...2.7...4...8...8....4...7.4...6...7...73...5...4.2...7...2...
.2...7...2.7...7...3....2...8...7.4...3...3....9...4...4.3...5...4
3...8...6...3.2...3....4...7...7...2.8...5....9...1...7...8.9...7.
...6...8...3...9.2...41...5...7...5...2.3....3...4...2...3...3.3..
..2...7...3...5...3.3....7...8...3...7...3.5....6...7...4...4...5.
.7...5...6...6...2....7.7...6...5...6...3....7.8...5...7...7...5..
..8.7...7...7...7...6....7.3...3...4...7...85...3.4...5...4...4...
.6...4.3...4...4...4....5...3.7...7...5...7....7...7.6...5...7...9
6...3...6.4...4...4....5...5...4.7...7...5....7...4...7.6...5...7.
...7...7...6.7...6...46...4...5...7.3...6....6...4...4...3.7...4..
..7...4...7...7.7...6....7...5...5...7.4...72...7...7...6...4.7...
.3...4...4...6...7.6....5...4...5...4...6.4....6...7...7...6...4.8
....8...9...4...7...8..7...7...4...6...2....7.2...9...3...9...7...
.2.8...6...8...6...6....8.8...6...6...8...9....8.3...7...8...4...8
7...3.4...5...6...4....9...4.7...8...3...3....6...7.7...7...7...8.
...6...7.4...8...7...54...7...4.2...7...2....3...5...2.8...8...3..
..8...8...8.4...7...7....6...7...4.4...8...56...8...8...4.5...3...
.9...6...7...5.9...8....6...3...8...9.9...9....8...7...7...9.5...4
2...4...7...8...5.5....7...4...2...3...5.7....6...3...3...8...7.3.
...9...8...7...9...3.5....8...5...5...4...5..2...6...6...8...2....
2.4...8...5...7...3....4.7...7...7...6...5....7.7...6...6...7...7.
...7.1...6...8...4...46...1.2...5...8...4....8...2.1...9...1...8..
..7...1.5...8...5...7....6...5.3...7...6...66...6...3.2...6...3...
.5...5...2.7...5...7....7...9...7.2...5...7....6...8...2.2...7...6
8...8...7...2.2...7....7...8...6...2.8...7....6...1...5...8.8...7.
...7...5...5...8.2...92...4...6...7...2.6....3...4...3...7...6.5..
..5...8...7...7...5.2....7...7...7...7...2.9....4...6...6...9...9.
..5...4...4...4...3......8...8...7...5...2..5...5...5...7...2...2.
.8...5...7...8...8...7..5...2...6...8...5......5...3...7...4...3..
4...2...7...8.......8..8...3...7...4...3...6..5...7...5...5...5...
...7...7...7...6...5..4...6...5...9...6...3..7...7...7...3...6...6
..7...8...9...3...8......8...4...3...8...7..4...8...5...3...7...7.
.5...4...6...8...6...7..2.......6...7...3......8...3...6...6...2..
3...5...5...8...3...2..2...3...5...7...2...5..2...8...3...7...2...
...7...6...6...7...5....7...5...4...7...6......8...7...8...8...2..
7...7...4...6...3...1..8...4...7...8...8...7..7...2...9...7...5...
...4...2...8...7...5..5...2...2...8...9...9..7...2...5...8...6...9
..4...2...7...9...2......7...5...8...8...6..4...9...7...5...4...2.
.8...8...8...3...8...9..6...8...5...4...5......8...8...3...9...6..
7...7...9...4...6...7..8...7...8...9...8...9..3...9...4...6...3...
...8...6...8...8...2..6...5...2...5...3...3..2...5...6...6...2...9
..1...9...2...7...3......7...9...9...9...9....7...9...4...8...8...
...9...8...7...8...6..7...8...3...9...2...3..9...7...7...8...2...7
..8...2...7...8...4......7...2...9...5...5..9...2...8...8...9...9.
.8...2...5...9...6...8..3...8...3...9...2......7...5...7...8...7..
4...7...3...9...9...6..7...9...7...5...9...8..9...8...9...8...6...
...8...9...5...9...8..8...8...9...8...8...8..8...5...8...9...8...6
..2...9...9...8...3......2...6...9...8...1..8...4...2...6...3...2.
.6...5...7...8...1...8..3...9...6...8...2......7...8...8...6...8..
...9...9...8...8...2......9...4...9...5...3......4...9...7...7...9
9.....9...9...9...9....9.....5...8...4...9....4.....3...9...7...6.
...9.....9...9...9...99...5.....9...9...9....4...3.....8...7...7..
..9...9.....7...5...6....9...9.....6...7...98...8...8.....7...8...
.9...9...7.....9...9....7...9...6.....9...8....9...9...7.....9...9
8...4...7...9.....9....5...7...5...9.....8....7...9...7...9.....9.
...9...9...8...9.....92...9...7...9...8......3...6...6...8...9....
..9...9...9...9...9.......6...2..................5...7............
......7......................3..............6.......4.............
.5.......3..............7.......2..............3.......9..........
2...4.......9..........7...3.......7..............2.......3...8...
.......9.......3..............9.......3..............7.......4....
..........3.......3..............3......................3.......8.
.............4.......6..........8...3.............................
................8......................6......7...6...6...7...7...
...9...8...7.......3..7...5...7...9...6...5..9...9...9...8...8...9
..5...3...6...7...3......9...2...8.......7..6...3...5...9...8...7.
.8...2...7...8...7...7..7...5...8...8...6......9...7...7.......6..
6...6...8...9...6...5..7...8...7...5...7...9..9...9...9...9...8...
...8...8...5.......8..7...7...8...9...8...9.......................
..6...8...6...8...6......8...7...7.......2..7...3...6...8...6...3.
.3...7...6...8...2...9..5...7...5...9...3......9...7...9.......9..
.4...4...9...7...1....4.3...9...9...7...3....3.9...9...7...9...5..
..9.9...7...9...9...9....9.2...9...5...9...64...2.7...5...4...5...
.9...7.2...9...1...9....9...2.4...5...7...9....7...4.4...7...9...7
9...9...4.3...6...4....9...5...3.3...9...9....7...9...3.3...6...6.
...9...5...3.7...9...97...5...7...7.4...9....7...4...6...4.9...8..
..9...1...9...9.9...9....9...7...6...9.4...61...9...9...9...4.6...
.3...5...4...9...6.7....5...9...9...8...7.5....9...9...6...9...5.4
....6...7...9...6...4..6...5...6...5...3....6.2...6...4...7...2...
.2.8...5...6.......5....8.5...3...5...5...5....5.2...5...4...3...7
5...2.4...5...5...5....6...4.2...7.......7....5...2.3...7...5...5.
...3...3.4...4...5...86...5...4.3...6...3....4...5...3.6.......4..
..6...7...6.6...6...5....5...7...6.3...5...55...4...4...3.6...5...
.7...5...6...6.....5...........................5...5...6.....7...5
3...3...5...5...7.4....2...5...3...5...4.7....5...7...4...5...7.6.
...5...5...5.......6.4....7...8...5...5...4....9...9...9.......2..
....9...9...9...6..........6...7...9...9...79.....9...9...9...9...
.9.........9.......9....6.....4...9...5...9....9.....9...9...9...9
9.........9...9...9....9...4.....9.......9....7...9.....9...7...9.
...9...9.....7...9...69...9...9.....9...9....9...9...9.........9..
..9...9...7.....9...9....9...9...9.....9...9......................
.6...5...7...9.....9....9...9...9...9.....9....9...9...9..........
2...9...9...9...9..........9...9...9...9......7...9...6...9.......
;

data ratings;
   input Sweet Refreshing Healthy Good SimpleTasting Alcohol
         Watery Sodas Colas Juices Opaques /
         @1 _name_ $16. @26 label $16.;
         KidDrink = sodas + colas + juices;

   label SimpleTasting = 'Simple Tasting';
   datalines;
 2.84615 4.13461 7.50000 5.65385 5.86538 0 0 0 1 0 0
Coke            Cola     Coke
 2.65385 4.50000 7.17308 5.61538 4.55769 0 0 1 0 0 0
OrangeSoda      Soda     Orange Soda
 3.33333 4.40385 7.11538 6.00000 4.15385 0 0 1 0 0 0
LemonKoolAid     Soda     Lemon Koolaid
 6.46154 3.96154 2.36538 2.07692 4.50980 0 0 0 0 0 1
Milk            Watery   Milk
 6.92157 4.86274 5.55769 4.28846 4.28000 0 1 0 0 0 0
HotTea          Watery   Hot Tea
 6.66667 3.29412 5.42308 3.92308 4.00000 0 1 0 0 0 0
IceTea          Watery   Ice Tea
 7.41176 5.23529 6.63461 5.01923 5.07843 0 1 0 0 0 0
HotCoffee       Watery   Hot Coffee
 7.19608 6.27451 7.00000 6.62745 5.30000 0 1 0 0 0 0
Icecofee        Watery   Iced Coffee
 7.76923 3.32692 1.36538 2.01923 1.67308 0 1 0 0 0 0
Water           Watery   Water
 3.36538 2.72549 2.09615 1.96154 4.30769 0 0 0 0 1 0
AppleJuice      Juice    Apple Juice
 3.40385 3.11538 2.50000 2.46154 4.80769 0 0 0 0 1 0
GrapeJuice      Juice    Grape Juice
 5.97872 6.56522 7.56000 6.16327 6.58696 1 0 0 0 0 0
Rum             Alcohol  Rum
 6.58333 5.24490 6.42000 5.58000 6.39583 1 0 0 0 0 0
Beer            Alcohol  Beer
 5.06383 5.77083 5.50000 4.72000 6.85106 1 0 0 0 0 0
Wine            Alcohol  Wine
 7.20930 6.86667 7.61224 6.68085 6.44444 1 0 0 0 0 0
Scotch          Alcohol  Scotch
 6.25000 6.93333 5.80435 6.71739 6.20000 0 1 0 0 0 0
Postum          Watery   Postum
 2.92308 3.73077 6.80392 4.78431 4.30769 0 0 1 0 0 0
SevenUp         Soda     7 Up
 2.09615 4.75000 7.48077 6.15385 6.00000 0 0 0 1 0 0
DrPepper        Cola     Dr. Pepper
 3.78846 2.80769 4.07692 3.23077 4.11538 0 0 1 0 0 0
Lemonade        Soda     Lemonade
 2.51923 3.88461 7.36538 5.73077 5.40385 0 0 0 1 0 0
PepsiCola       Cola     Pepsi Cola
 2.49020 4.03846 6.90385 5.48077 4.80392 0 0 1 0 0 0
OrangeCrush     Soda     Orange Crush
 5.92308 4.48077 2.48077 2.94231 6.43137 0 0 0 0 0 1
V8Juice         Juice    V8 Juice
;

proc mds data=dissim maxiter=2 /* MAXITER= should be bigger!!!! */
   level=interval model=indscal dimens=2 header out=config;
run;

proc sort data=config(where=(_type_ = 'CONFIG')
                      keep=_type_ _name_ dim1 dim2);
   by _name_;
run;

proc sort data=ratings(keep=_name_ label Sweet -- SimpleTasting);
   by _name_;
run;

data both(drop=_type_);
   merge config ratings;
   by _name_;
run;

proc transreg data=both;
   model identity(Sweet -- SimpleTasting / reverse) =
         identity(dim1 dim2);
   output out=coor coo replace;
   id label;
run;

%plotit(data=coor, datatype=mds vector 1.7)

****************************************************************
*   Title: Miscellaneous Illustrations Of The Plotit Macro     *
****************************************************************;

title "Principal Components of Mammals' Teeth";

data teeth;
     input prin1 prin2 mammal $ 20.;
     label prin1 = 'Dimension 1' prin2 = 'Dimension 2';
     datalines;
-1.07861     2.49571    Reindeer
-1.07861     2.49571    Elk
-1.91645     2.06224    Deer
-1.91645     2.06224    Moose
 0.20963     1.11008    Brown Bat
 1.63582     0.95908    Wolf
 1.63582     0.95908    Bear
-0.81127     0.93458    Red Bat
-0.14183     0.92850    Silver Hair Bat
 1.68822     0.79958    Raccoon
-0.48191     0.63206    Pigmy Bat
-0.83336     0.45049    House Bat
-0.42183     0.22803    Mole
 2.49881     0.14660    Marten
 2.49881     0.14660    Wolverine
 2.15874    -0.14983    River Otter
 1.80728    -0.33141    Weasel
 1.80728    -0.33141    Badger
 1.23632    -0.68499    Grey Seal
-2.09478    -0.87943    Rabbit
 1.64162    -1.01148    Sea Otter
 2.79084    -1.01947    Fur Seal
 2.79084    -1.01947    Sea Lion
-3.11568    -1.05493    Beaver
-3.11568    -1.05493    Groundhog
-2.44624    -1.06101    Pika
 1.92490    -1.11384    Jaguar
 1.92490    -1.11384    Cougar
-3.46713    -1.23651    Gray Squirrel
-3.46713    -1.23651    Porcupine
 2.29581    -1.39702    Elephant Seal
-4.15867    -1.71452    House Mouse
;

%plotit(data=teeth)

title 'Crime Rates Per 100,000 Population by State';

data crime;
   input State $1-15 Murder Rape Robbery Assault Burglary
         Larceny Auto PostalCode $;
   datalines;
Alabama        14.2 25.2  96.8 278.3 1135.5 1881.9 280.7  AL
Alaska         10.8 51.6  96.8 284.0 1331.7 3369.8 753.3  AK
Arizona         9.5 34.2 138.2 312.3 2346.1 4467.4 439.5  AZ
Arkansas        8.8 27.6  83.2 203.4  972.6 1862.1 183.4  AR
California     11.5 49.4 287.0 358.0 2139.4 3499.8 663.5  CA
Colorado        6.3 42.0 170.7 292.9 1935.2 3903.2 477.1  CO
Connecticut     4.2 16.8 129.5 131.8 1346.0 2620.7 593.2  CT
Delaware        6.0 24.9 157.0 194.2 1682.6 3678.4 467.0  DE
Florida        10.2 39.6 187.9 449.1 1859.9 3840.5 351.4  FL
Georgia        11.7 31.1 140.5 256.5 1351.1 2170.2 297.9  GA
Hawaii          7.2 25.5 128.0  64.1 1911.5 3920.4 489.4  HI
Idaho           5.5 19.4  39.6 172.5 1050.8 2599.6 237.6  ID
Illinois        9.9 21.8 211.3 209.0 1085.0 2828.5 528.6  IL
Indiana         7.4 26.5 123.2 153.5 1086.2 2498.7 377.4  IN
Iowa            2.3 10.6  41.2  89.8  812.5 2685.1 219.9  IA
Kansas          6.6 22.0 100.7 180.5 1270.4 2739.3 244.3  KS
Kentucky       10.1 19.1  81.1 123.3  872.2 1662.1 245.4  KY
Louisiana      15.5 30.9 142.9 335.5 1165.5 2469.9 337.7  LA
Maine           2.4 13.5  38.7 170.0 1253.1 2350.7 246.9  ME
Maryland        8.0 34.8 292.1 358.9 1400.0 3177.7 428.5  MD
Massachusetts   3.1 20.8 169.1 231.6 1532.2 2311.3 1140.1 MA
Michigan        9.3 38.9 261.9 274.6 1522.7 3159.0 545.5  MI
Minnesota       2.7 19.5  85.9  85.8 1134.7 2559.3 343.1  MN
Mississippi    14.3 19.6  65.7 189.1  915.6 1239.9 144.4  MS
Missouri        9.6 28.3 189.0 233.5 1318.3 2424.2 378.4  MO
Montana         5.4 16.7  39.2 156.8  804.9 2773.2 309.2  MT
Nebraska        3.9 18.1  64.7 112.7  760.0 2316.1 249.1  NE
Nevada         15.8 49.1 323.1 355.0 2453.1 4212.6 559.2  NV
New Hampshire   3.2 10.7  23.2  76.0 1041.7 2343.9 293.4  NH
New Jersey      5.6 21.0 180.4 185.1 1435.8 2774.5 511.5  NJ
New Mexico      8.8 39.1 109.6 343.4 1418.7 3008.6 259.5  NM
New York       10.7 29.4 472.6 319.1 1728.0 2782.0 745.8  NY
North Carolina 10.6 17.0  61.3 318.3 1154.1 2037.8 192.1  NC
North Dakota    0.9  9.0  13.3  43.8  446.1 1843.0 144.7  ND
Ohio            7.8 27.3 190.5 181.1 1216.0 2696.8 400.4  OH
Oklahoma        8.6 29.2  73.8 205.0 1288.2 2228.1 326.8  OK
Oregon          4.9 39.9 124.1 286.9 1636.4 3506.1 388.9  OR
Pennsylvania    5.6 19.0 130.3 128.0  877.5 1624.1 333.2  PA
Rhode Island    3.6 10.5  86.5 201.0 1489.5 2844.1 791.4  RI
South Carolina 11.9 33.0 105.9 485.3 1613.6 2342.4 245.1  SC
South Dakota    2.0 13.5  17.9 155.7  570.5 1704.4 147.5  SD
Tennessee      10.1 29.7 145.8 203.9 1259.7 1776.5 314.0  TN
Texas          13.3 33.8 152.4 208.2 1603.1 2988.7 397.6  TX
Utah            3.5 20.3  68.8 147.3 1171.6 3004.6 334.5  UT
Vermont         1.4 15.9  30.8 101.2 1348.2 2201.0 265.2  VT
Virginia        9.0 23.3  92.1 165.7  986.2 2521.2 226.7  VA
Washington      4.3 39.6 106.2 224.8 1605.6 3386.9 360.3  WA
West Virginia   6.0 13.2  42.2  90.9  597.4 1341.7 163.3  WV
Wisconsin       2.8 12.9  52.2  63.7  846.9 2614.2 220.7  WI
Wyoming         5.4 21.9  39.7 173.9  811.6 2772.2 282.0  WY
;

proc princomp data=crime out=crime;
run;

%plotit(data=crime, label=typical, symvar=postalcode,
        labelvar=state, plotvars=prin2 prin1,
        paint=murder, symsize=0.6, symlen=2)

title 'Crude Death Rate as a Function of Crude Birth Rate';

data vital;
   input country $ 1-20 Births Deaths;
   datalines;
USA                  15 9
Afghanistan          52 30
Algeria              50 16
Angola               47 23
Argentina            22 10
Australia            16 8
Austria              12 13
Bangladesh           47 19
Belgium              12 12
Brazil               36 10
Bulgaria             17 10
Burma                38 15
Cameroon             42 22
Canada               16 7
Chile                22 7
China                31 11
Taiwan               26 5
Colombia             34 10
Cuba                 20 6
Czechoslovakia       19 11
Ecuador              42 11
Egypt                39 13
Ethiopia             48 23
France               14 11
German Dem Rep       12 14
Germany, Fed Rep Of  10 12
Ghana                46 14
Greece               16 9
Guatemala            40 14
Hungary              18 12
India                36 15
Indonesia            38 16
Iran                 42 12
Iraq                 48 14
Italy                14 10
Ivory Coast          48 23
Japan                16 6
Kenya                50 14
Korea, Dem Peo Rep   43 12
Korea, Republic Of   26 6
Madagascar           47 22
Malaysia             30 6
Mexico               40 7
Morocco              47 16
Mozambique           45 18
Nepal                46 20
Netherlands          13 8
Nigeria              49 22
Pakistan             44 14
Peru                 40 13
Philippines          34 10
Poland               20 9
Portugal             19 10
Rhodesia             48 14
Romania              19 10
Saudi Arabia         49 19
South Africa         36 12
Spain                18 8
Sri Lanka            26 9
Sudan                49 17
Sweden               12 11
Switzerland          12 9
Syria                47 14
Tanzania             47 17
Thailand             34 10
Turkey               34 12
USSR                 18 9
Uganda               48 17
United Kingdom       12 12
Upper Volta          50 28
Venezuela            36 6
Vietnam              42 17
Yugoslavia           18 8
Zaire                45 18
;

%plotit(data=vital, vtoh=1.75, datatype=curve2)

%plotit(data=vital, vtoh=1.75, datatype=curve2, bright=128,
        symvar=country, regfun=msp, regopts=nkn=2)

title 'Some Functions';

data x;
   inc = 0.1; keep x y _type_;
   do x = inc to 10 by inc;
      y = log(x);  _type_ = 'log '; output;
      y = sqrt(x); _type_ = 'sqrt'; output;
      y = sin(x);  _type_ = 'sin '; output;
      y = cos(x);  _type_ = 'cos '; output;
      y = log2(x); _type_ = 'log2'; output;
   end;
run;

%plotit(data=x, datatype=function)

title 'A Function And Its Derivative And Integral';

data x;
   keep x y _type_;
   inc = 0.1; int = 0; oldy = exp(-0.5 * ((-2 - inc) ** 2));
   do x = -2 to 2 by inc;
      y = exp(-0.5 * (x ** 2));
      _type_ = 'Function  '; output; ty = y;
      y = (y - oldy) / inc;
      _type_ = 'Derivative'; output; oldy = ty;
      int = int + ty * inc; y = int;
      _type_ = 'Integral'; output;
   end;
run;

%plotit(data=x, datatype=function, symvar=_type_, symlen=10,
        adjust5=%str(if first.obstype or last.obstype then do;
        output; size=0.5; if first.obstype then position = '<';
        else position = '>'; function = 'LABEL'; output; end;))

title 'Artificial Profiles for Four Groups';

data x;
   do x = 1 to 5;
      _type_ = 'A'; y = .1 + log10(x); output;
      _type_ = 'B'; y = .2 + log(x);   output;
      _type_ = 'C'; y = .3 + log2(x);  output;
      _type_ = 'D'; y = .5 + sqrt(x);  output;
      output;
   end;
run;

%plotit(data=x, datatype=function, plotvars=y x,
        adjust5=%str(output; function = 'LABEL'; text = obstype;))

title ;
footnote 'Artificial Profiles for Four Groups';
%plotit(data=x, datatype=function, plotvars=y x, extend=-1 . . -1,
        framecol=&cback, href=0, vref=0, options=noback,
        adjust5=%str(output; function = 'LABEL'; text = obstype;),
        adjust4=%str(
        if index(comment, 'vref') or index(comment, 'href')
           then color = 'black';
        if index(comment, 'text, x') then y = y + 1;
        if index(comment, 'text, y') then x = x + 2;))

footnote;

title  'Regression Function';
title2 'Make Points with the Largest Residuals Magenta and Red';

data x;
   do x = 1 to 10 by 0.1;
      y = 4 + sin(x) + normal(7);
      output;
   end;
run;

proc transreg data=x;
   model ide(y) = spl(x / nkn=4);
   output p r out=res;
run;

data res2;
   set res;
   ry = abs(ry);
   _type_ = 'd';         output;
   _type_ = 'p'; y = py; output;
run;

%plotit(data=res2, plotvars=y x, types=d p, labelvar=_blank_,
        symtype=symbol function, paint=ry);

title 'Cowboy Hat';

data hat;
   _type_ = 1;
   do x = -5 to 5 by 0.2;
      do y = -5 to 5 by 0.2;
         z = sin(sqrt(x * x + y * y));
         output;
      end;
   end;
run;

%plotit(data=hat, plotvars=y x, paint=z, datatype=contour,
        options=expand, extend=close)

title 'Spiral';

data x;
   stop = 3.1415 * 32;
   do i = 0 to stop by 0.1;
      x = 0.1 * i * cos(i);
      y = 0.1 * i * sin(i);
      output;
   end;
run;

%plotit(data=x, plotvars=y x, paint=i,
        adjust4=%str(
        if text = 'star' then do;
           size = 2;
           if n = 1 then function = 'MOVE';
           else function = 'DRAW';
           end;))

title 'Wall Paper';

data x;
   do x = -5 to 5 by 0.1;
      do y = -5 to 5 by 0.1;
         z = sqrt((x - round(x)) ** 2 + (y - round(y)) ** 2);
         output;
      end;
   end;
run;

%plotit(data=x, datatype=contour, extend=close, plotvars=y x,
         options=expand, paint=z red orange yellow magenta blue)

title 'A Contour Plot of the Swirl Data Set';

data swirl;
   do x = -5 to 5 by 0.125;
      do y = -5 to 5 by 0.125;
         z = x * x + y * y;
         if z > 1e-8 then z = x * y * (x * x - y * y) / z;
         output;
      end;
   end;
run;

%plotit(data=swirl, datatype=contour, options=expand, extend=close,
        paint=z red orange yellow magenta blue)

title 'Bivariate Normal Density Function';

proc iml;
   s = inv({1 0.25 , 0.25 1});
   m = -2; n = 2; inc = 0.05; k = 0;
   x = j((1 + (n - m) / inc) ** 2, 3, 0);
   c = sqrt(det(s)) / (2 * 3.1415);
   do i = m to n by inc;
      do j = m to n by inc;
         v = i || j; z = c * exp(-0.5 * v * s * v`);
         k = k + 1; x[k,] = v || z;
      end;
   end;
   create x from x[colname={'x' 'y' 'z'}]; append from x;
   quit;

%plotit(datatype=contour, data=x, options=expand, excolors=CXFFFFFF,
        paint=z white white yellow orange red magenta blue)

****************************************************************
*   Title: Preference Ratings For Recreational Activities      *
****************************************************************;

title 'Multidimensional Preference Analysis of Recreational Activities';

data recreate;
   input (sub1-sub56) (1.) +1 (Active Relaxing SpectatorSport) (1.) /
         activity $27.;
   datalines;
81995594778986997959995994679798979839997799899982999839 090
Reading
09730303952308890002030047206103000204109172003105177071 540
Golf
52969324243446595836553383884325711366753545194625434653 090
Watching TV
12849367411106584033051000737158220004817200004207756030 540
Tennis
13311939156005211000222017951301400574021431175004009031 540
Sailing
07003283541004462117095706697507210214408143001513271090 199
Attending a Football Game
80525573612060248733735765174347933215263203392263676907 190
Going to the Symphony
15123140466205898031283028284913100634117311010119200060 540
Softball
07009277641175872112095427896537340517708179051907275590 199
Attending a Basketball Game
79010280115009140007020157451201300177182274620101002202 380
Fishing
88532484130359482461412548471342493574202497842521357238 740
Bicycling
55436757173367411510433252381603555595091357805640757408 740
Hiking
56314552120736451361853959333873610585324627700124058996 740
Swimming
15216312111756420020016000849002580424273059403100093790 830
Running
33231584134220072200052542010601400334103200008013505002 080
Chess
16371850120027280030053008231409010716003101000003000000 640
Racquetball
77647366111259815782454388871684907387262408409845791965 640
Walking
69549314133075512081602179571194906065161043909220094838 480
Gardening
05017328142045570652082204497231010121909200001609156090 640
Basketball
07208556185050783625094005897307050325908158190806353680 099
Watching Sports on TV
25221796180206410021112073492807261696191060850015121408 440
Camping
08000200020000010004000010100000000202022303000004001000 480
Hunting
16224596115228281703040226180006100554114108055233851006 180
Billiards
14522325103124286050052003130706310214504303005203957000 480
Ping Pong
16063535133000368450053133356743500644105443000324158280 540
Volleyball
16158114110500480353440435352465600244444427302112100004 440
Bowling
56858385551954782824874483575575651487575677195815756687 090
Watching a Rented Movie
15432353210029610050000008424680610101054201009111100270 930
Aerobics
42719802100206672030021000691605070144062802500027100220 640
Snow Skiing
00710100000040507090400022300000702004030100209010000644 180
Sewing
76985675521954786837885773588755933585266777155756354738 190
Going to a Movie
67708372497000787145096304299626210514137425013625550564 199
Attending a Baseball Game
;

proc prinqual cor data=recreate out=b score std rep;
   transform identity(sub:);
   id activity active relaxing spectatorsport;
run;

%plotit(data=b, datatype=mdpref 3)

%plotit(data=b, datatype=mdpref2 3, symlen=2, vechead=,
        adjust1=%str(
        if _type_ = 'CORR' then do;
           __symbol = substr(activity,4);
           __ssize  = 0.7;
           activity = ' ';
           end;))

proc transreg data=b;
   title2 'Preference Mapping';
   model ide(active relaxing spectatorsport) = ide(prin1 prin2);
   output out=vector coo replace;
   id activity;
run;

%plotit(data=vector, datatype=vector 1.2)

proc transreg data=b;
   model ide(active relaxing spectatorsport) = point(prin1 prin2);
   output out=point coo replace;
   id activity;
run;

%plotit(data=point, datatype=ideal, antiidea=1)

options nogstyle;
title 'Heteroscedastic AR(1) Covariance Matrix';

data x;
   input col1-col7;
   x = _n_;
   array c[7] col1-col7;
   do y = 1 to 7;
      z = c[y];
      t = 1; l = '     ';    output;
      t = 2; l = put(z,5.2); output;
   end;
   drop col1-col7;
   datalines;
2.56694 2.52647 2.78644  2.9153  2.3903  2.1764  1.6605
2.52647 4.24754 4.68460  4.9013  4.0187  3.6590  2.7917
2.78644 4.68460 8.82537  9.2335  7.5708  6.8932  5.2594
2.91531 4.90126 9.23354 16.5017 13.5302 12.3191  9.3992
2.39034 4.01868 7.57083 13.5302 18.9497 17.2535 13.1641
2.17638 3.65896 6.89316 12.3191 17.2535 26.8335 20.4735
1.66054 2.79173 5.25936  9.3992 13.1641 20.4735 26.6828
;

%plotit(data=x, symvar=l, labelvar=_blank_, symlen=5, typevar=t,
        color=&cback, excolors=&cback, tickcol=black, titlecol=black,
        colors=black, plotopts=vreverse, exttypes=contour, font=none,
        rgbtypes=contour, types=1 2, symtype=contour symbol,
        symfont=solid none, paint=z violet orange red, options=expand,
        adjust4=%str(if comment =: 'text, x tick' then y = top + 2;
                     if comment =: 'text, title'  then y = bottom;
                     ))

title "Kuhfeld's Comet";

data x;
   keep y x l z _type_;
   pi  = 3.1415;
   inc = pi / 64;
   _type_ = '0';
   do t = -pi + inc to pi by inc;
      x = cos(t) - 3;
      y = sin(t) - 3;
      z = x + y;
      l = ' ';
      output;
   end;
   x = -3; y = -3; z = x + y; _type_ = '1'; output;
run;

%plotit(data=x, lsizes=0 0 1 10 0, color=&cback, titlecol=blue,
        colors=red, symtype=vector circle, options=noback, font=none,
        symbols='', vechead=, radii=0 to 1 by .05)

title 'Love Birds';

data x;
   pi = 3.1415; inc = pi / 64; drop pi inc;
   t = 1;
   do x = -pi to 1.25 * pi by inc; y = sin(x); output; end;
   t = 2;
   do x = -0.75 * pi to 1.5 * pi by inc; y = cos(x); output; end;
   t = 3;
   do x = 0.625 * pi to 1.25 * pi by inc;
      y = 0.22 + cos(x - pi / 8); output;
   end;
   t = 4;
   do x = -0.75 * pi to -0.125 * pi by inc;
      y = 0.22 + sin(x + pi / 8); output;
   end;
run;

%plotit(data=x, color=&cback, titlecol=blue, plotvars=y x, font=none,
         options=noback, colors=blue, typevar=t, datatype=function)

title 'Bowtie';

data x;
   pi  = 3.1415; inc = pi / 64; drop pi inc;
   do x = -1.5 * pi to 1.5 * pi by inc;
      y = cos(x); output;
      y = -y;   ; output;
   end;
run;

%plotit(data=x, plotvars=y x, symtype=vector, vechead=, color=&cback,
        titlecol=red, rgbround=0 16 16 16, symbols='', bright=128,
         options=noback, britypes=vector, font=none)

options gstyle;