Example 2.1. Listing Selected Observations in a Specific Order

Goal

List specific information about selected observations in a data set in a specific order. Each row in the report presents information for one observation.

Report

                         Selected Listing of Local
 Residential Properties
                               Price Range $200
,000 to $350,000

  Residential     House                           
     Listing                     Square
  Zone            Style     Address               
        Price Bedrooms Bathrooms  Feet  Age

  North Ridge     bungalow  6008 Brass Lantern Ct.
    $344,500      3       2.5    2,416    6
  Inside Beltline capecod   100 Cumberland Green  
    $343,000      3       2.5    1,650    0
  East Lake       ranch     8122 Maude Steward Rd.
    $329,900      3       3.0    2,400    2
  Roebuck         split     110 Skylark Way       
    $323,500      3       2.0    1,976   10
  North Ridge     colonial  4000 Skipjack Ct.     
    $314,900      3       2.5    2,750    0
  Roebuck         split     5617 Laurel Crest Dr. 
    $286,900      3       1.5    1,441   28
  North Ridge     split     2414 Van Dyke         
    $285,000      3       1.0    1,245   36
  Inside Beltline townhouse 765 Crabtree Crossing 
    $284,000      3       2.0    1,471    1
  North Ridge     split     500 E. Millbrook Rd.  
    $282,900      3       1.5    1,329   23
  East Lake       split     6424 Old Jenks Rd.    
    $281,900      3       1.5    1,225   18
  Inside Beltline split     101 Meadowglade Ln.   
    $279,950      3       2.0    2,004    0
  Inside Beltline townhouse 108 Chattle Close     
    $279,900      3       2.5    2,080    4
  Westend         split     Rt.5 Yarbororugh Rd.  
    $278,900      2       1.0      960    2
  Roebuck         townhouse 8 Stonevillage        
    $271,000      2       2.0    1,276    6
  Ensley          townhouse 409 Galashiels        
    $260,000      2       1.5    1,280    4
  East Lake       split     4341 Rock Quarry      
    $260,000      3       1.0    1,010   28
  Inside Beltline townhouse 216 Concannon Ct.     
    $259,900      2       1.5    1,040    9
  Inside Beltline townhouse 1239 Donaldson Ct.    
    $249,900      2       1.5    1,150   15
  Westend         split     603 Greentree Dr.     
    $217,800      3       2.0    1,533    5
  East Lake       ranch     6509 Orchard Knoll    
    $207,900      3       2.0    1,526    6
  Southside       townhouse 154 Montrose          
    $202,000      2       2.0    1,595    6
  Mountain Brook  duplex    108 South Elm St.     
    $200,000      3       1.0    1,569   73
  North Ridge     split     6324 Lakeland, Lake
 Park  $200,000      3       2.0    1,662   12

                       Total Available Properties
 within Price Range: 23


Example Features

Data SetHOUSING
Preparatory StepPROC SORT
Featured StepPROC PRINT
Featured Step Statements and OptionsPROC PRINT statement: N= option

VAR statement

WHERE statement
Formatting FeaturesPROC PRINT statement: NOOBS and SPLIT= options PROC PRINT statement: UNIFORM option when sending output to the LISTING destination
Other Examples That Use This Data SetExamples 2.2 and 6.1

Example Overview

This report lists observations from the HOUSING data set. It presents data about houses for sale within a specific price range and arranges the observations in descending order of price.

Each row in the report corresponds to one observation in the HOUSING data set. Each column corresponds to one variable.

The data set must be sorted before the PROC PRINT step. A VAR statement within the PROC PRINT step selects the variables to list in the report. A WHERE statement within the PROC PRINT step selects the observations to list in the report.

Program

Sort the observations by the descending values of PRICE.
proc sort data=housing;
  by descending price;
run;

Create a format that can associate meaningful descriptions to the numeric values of the variable ZONE.
proc format;
  value $zonefmt '1'='North Ridge'
                 '2'='Inside Beltline'
                 '3'='Southside'
                 '4'='East Lake'
                 '5'='Westend'
                 '6'='Mountain Brook'
                 '7'='Ensley'
                 '8'='Roebuck';
run;

Print the sorted data set.
proc print data=housing

Print the number of observations in the data set and specify explanatory text to print with the number.
     n='Total Available Properties within
        Price Range: '

Suppress the column in the output that identifies each observation by number.
     noobs

Specify the split character that controls line breaks in column headings. (The SPLIT= option causes variable labels to be used as column headings. If you want labels, but do not need to specify a split character, replace SPLIT= with the keyword LABEL.)
     split='/'

Format all pages of a multipage report uniformly when sending output to the LISTING destination.
     uniform;

 
  title 'Selected Listing of Local Residential
         Properties';
  title2 'Price Range $200,000 to $350,000';

Select the observations to include in the report.
  where price between 200000 and 350000;

List the variables in the order in which they should appear in the report.
  var zone type address price bedr bath sqfeet age;

Associate formats with variables.
  format sqfeet comma5. price dollar9.
         zone $zonefmt.;

Label the variables in the report. Include the split character within the label to control line breaks in the heading for the variable.
  label zone='Residential/Zone'
        type='House/Style'
        address='Address'
        price='Listing/Price'
        bedr='Bedrooms'
        bath='Bathrooms'
        sqfeet='Square/Feet'
        age='Age';
run;


Where to Go from Here

BY statement processing. See “BY Statement” in the “Statements” section of SAS 9.1 Language Reference: Dictionary, and “Statements with the Same Function in Multiple Procedures” in the “Concepts” section of Base SAS 9.1 Procedures Guide.

PROC PRINT reference, usage information, and additional examples. See “The PRINT Procedure” in the “Procedures” section of Base SAS 9.1 Procedures Guide.

WHERE statement processing. See “WHERE Statement” in the “Statements” section of SAS 9.1 Language Reference: Dictionary, and “WHERE-Expression Processing” in the “SAS System Concepts” section of SAS 9.1 Language Reference: Concepts.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.100.20