Previous Page | Next Page

Working with Grouped or Sorted Observations

Input SAS Data Set for Examples

Tradewinds Travel has an external file that contains data about tours that emphasize either architecture or scenery. After the data is created in a SAS data set and the observations for those tours are grouped together, SAS can produce reports on each group separately. In addition, if the observations need to be alphabetized by country, SAS can sort them. The external file looks like this:

1           2              3   4    5   
Spain       architecture  10  510 World
Japan       architecture   8  720 Express
Switzerland scenery        9  734 World
France      architecture   8  575 World
Ireland     scenery        7  558 Express
New Zealand scenery       16 1489 Southsea
Italy       architecture   8  468 Express
Greece      scenery       12  698 Express

The numbered fields represent

[1] the name of the destination country

[2] the tour's area of emphasis

[3] the number of nights on the tour

[4] the cost of the land package in US dollars

[5] the name of the tour vendor

The following DATA step creates the permanent SAS data set MYLIB.ARCH_OR_SCEN:

options pagesize=60 linesize=80 pageno=1 nodate;

libname mylib 'permanent-data-library';
data mylib.arch_or_scen;
   infile 'input-file' truncover;
   input Country $ 1-11 TourType $ 13-24 Nights LandCost Vendor $;
run;

proc print data=mylib.arch_or_scen;
   title 'Data Set MYLIB.ARCH_OR_SCEN';
run;

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

Data Set MYLIB.ARCH_OR_SCEN

                           Data Set MYLIB.ARCH_OR_SCEN                           1

                                                        Land
        Obs    Country        TourType        Nights    Cost    Vendor

         1     Spain          architecture      10       510    World   
         2     Japan          architecture       8       720    Express 
         3     Switzerland    scenery            9       734    World   
         4     France         architecture       8       575    World   
         5     Ireland        scenery            7       558    Express 
         6     New Zealand    scenery           16      1489    Southsea
         7     Italy          architecture       8       468    Express 
         8     Greece         scenery           12       698    Express 

Previous Page | Next Page | Top of Page