Previous Page | Next Page

Finding Shortcuts in Programming

Input File and SAS Data Set

In the following example, Tradewinds Travel is making adjustments to their data about tours to art museums and galleries. The data for the tours is as follows:

1         2  3 4  5        6 
Rome      4 3 . D'Amico  2
Paris     5 . 1 Lucas    5
London    3 2 . Wilson   3
New York  5 1 2 Lucas    5
Madrid    . . 5 Torres   4
Amsterdam 3 3 .          .

The numbered fields represent

[1] the name of the city

[2] the number of museums to be visited

[3] the number of art galleries in the tour

[4] the number of other attractions to be toured

[5] the last name of the tour guide

[6] the number of years of experience the guide has

The following program creates the permanent SAS data set MYLIB.ATTRACTIONS:

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

data mylib.attractions;
   infile 'input-file';
   input City $ 1-9 Museums 11 Galleries 13
         Other 15 TourGuide $ 17-24 YearsExperience 26;
run;

proc print data=mylib.attractions;
   title 'Data Set MYLIB.ATTRACTIONS';
run;

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

Data Set MYLIB.ATTRACTIONS

                           Data Set MYLIB.ATTRACTIONS                          1

                                                         Tour         Years
   Obs    City         Museums    Galleries    Other     Guide     Experience

    1     Rome            4           3          .      D'Amico         2    
    2     Paris           5           .          1      Lucas           5    
    3     London          3           2          .      Wilson          3    
    4     New York        5           1          2      Lucas           5    
    5     Madrid          .           .          5      Torres          4    
    6     Amsterdam       3           3          .                      .    

Previous Page | Next Page | Top of Page