Previous Page | Next Page

Acting on Selected Observations

Input SAS Data Set for Examples

Tradewinds Travel offers tours to art museums and galleries in various cities. The company has decided that in order to make its process more efficient, additional information is needed. For example, if the tour covers too many museums and galleries within a time period, then the number of museums visited must be decreased or the number of days for the tour needs to change. If the guide who is assigned to the tour is not available, then another guide must be assigned. Most of the process involves selecting observations that meet or that do not meet various criteria and then taking the required action.

The Tradewinds Travel tour data is stored in an external file that contains the following information:

1         2   3   4  5                 6        7 
Rome      3  750 7 4 M, 3 G          D'Amico  Torres
Paris     8 1680 6 5 M, 1 other      Lucas    Lucas
London    6 1230 5 3 M, 2 G          Wilson   Lucas
New York  6    . 8 5 M, 1 G, 2 other Lucas    D'Amico
Madrid    3  370 5 3 M, 2 other      Torres   D'Amico
Amsterdam 4  580 6 3 M, 3 G                   Vandever

The numbered fields represent

[1] the name of the city

[2] the number of nights in the city

[3] the cost of the land package (not airfare) in US dollars

[4] the number of events the trip offers (such as visits to museums and galleries)

[5] a brief description of the events (where M indicates a museum; G , a gallery; and other , another kind of event)

[6] the name of the tour guide

[7] the name of the backup tour guide

The following DATA step creates MYLIB.ARTTOURS:

options pagesize=60 linesize=80 pageno=1 nodate;
libname mylib 'permanent-data-library';

data mylib.arttours;
   infile 'input-file' truncover;
   input City $ 1-9 Nights 11 LandCost 13-16 NumberOfEvents 18 
         EventDescription $ 20-36 TourGuide $ 38-45 
         BackUpGuide $ 47-54;
run;

proc print data=mylib.arttours;
   title 'Data Set MYLIB.ARTTOURS';
run;

Note:   When the TRUNCOVER option is specified in the INFILE statement, and when the record is shorter than what the INPUT statement expects, SAS will read a variable length record.   [cautionend]

The PROC PRINT statement that follows the DATA step produces this display of the MYLIB.ARTTOURS data set:

Data Set MYLIB.ARTTOURS

                             Data Set MYLIB.ARTTOURS                            1
                                                               3        4 
                          Land   Number 1        2             Tour   BackUp
  Obs  City       Nights  Cost  OfEvents  EventDescription    Guide   Guide

   1   Rome          3     750      7     4 M, 3 G           D'Amico  Torres  
   2   Paris         8    1680      6     5 M, 1 other       Lucas    Lucas   
   3   London        6    1230      5     3 M, 2 G           Wilson   Lucas   
   4   New York      6       .      8     5 M, 1 G, 2 other  Lucas    D'Amico 
   5   Madrid        3     370      5     3 M, 2 other       Torres   D'Amico 
   6   Amsterdam     4     580      6     3 M, 3 G                    Vandever

The following list corresponds to the numbered items in the preceding output:

[1] the variable NumberOfEvents contains the number of attractions visited during the tour

[2] EventDescription lists the number of museums (M ), art galleries (G ), and other attractions (other ) visited

[3] TourGuide lists the name of the tour guide assigned to the tour

[4] BackUpGuide lists the alternate tour guide in case the original tour guide is unavailable

Previous Page | Next Page | Top of Page