Example 2.8. Presenting Long Text Fields in a Report

Goal

List observations in a data set where at least one of the character variables has a long length. Wrap the character data in the column assigned to the lengthy character variable.

Report

                                       Town Survey
                                    Comments Received

                 Years         Children
   Residential   Lived in       Under     Adults
   Area          Town            18?      Over 65?
  Comments
   -----------------------------------------------
------------------------------------
   Lakeside      < 2              No        No    
  Empty the garbage cans at the
                                                  
  parks more frequently

                 2-10            Yes        No    
  Too much paperwork to just remodel
                                                  
  a kitchen

                 More than 10    Yes        No    
  We loved the canoe derby

                                  No        No    
  Enforce the beach curfew

   Northwest     < 2             Yes        No    
  More organized sports for the kids

                 2-10             No       Yes    
  Replace wornout street signs

                                 Yes       Yes    
  We want snowmobile trails

                 More than 10    Yes        No    
  Advertise the brush pickup earlier
                                                  
  than two weeks before the pickup

                                  No       Yes    
  Change the yield sign to a stop
                                                  
  sign at W. Lake and Hilltop

   Prairie       2-10            Yes        No    
  Stop all outdoor burning because
                                                  
  it aggravates my asthma

                                  No        No    
  Enforce the leash laws. Add an off
                                                  
  leash dog park.

                 More than 10    Yes        No    
  Loved the community picnic

   Town Center   < 2              No        No    
  Partner with neighboring
                                                  
  communities to build a public
                                                  
  library

                                  No        No    
  City office is never open when I'm
                                                  
  off work. Please expand the hours.

                                 Yes       Yes    
  Plow the snow early and plow often

                                 Yes        No    
  More soccer fields now!!!

                                  No       Yes    
  Too many potholes

                 2-10            Yes        No    
  Please add more soccer fields

                                 Yes        No    
  Add rink lights for lacrosse and
                                                  
  hockey at night

                                 Yes        No    
  Salt the roads faster after each
                                                  
  snowfall

                 More than 10     No       Yes    
  Enforce the dog barking ordinance

                                 Yes        No    
  Our kids love the new playground
                                                  
  equipment


Example Features

Data SetTOWNSURVEY
Featured StepPROC REPORT
Featured Step Statements and OptionsDEFINE statement: FLOW, NOPRINT, ORDER, and ORDER= options

BREAK AFTER statement

Using the ORDER option to arrange observations by the variable while suppressing the display of the ordering variable with NOPRINT
Formatting FeaturesPROC REPORT statement: HEADLINE option when sending output to the LISTING destination

DEFINE statement: WIDTH option when sending output to the LISTING destination

BREAK AFTER statement: SKIP option when sending output to the LISTING destination
Other Examples That Use This Data SetExample 3.9

Example Overview

This report lists the comments that town residents gave in a survey of town services. Each set of lines that comprises a complete comment corresponds to one observation in the TOWNSURVEY data set. The report includes only the observations where a comment was recorded. Each column in the report corresponds to one variable in the input data set.

See Figure 3.9a in Example 3.9 for the form that collected the survey data.

Program

Create formats that can associate meaningful descriptions to values of the variables in the report.
proc format;
  value $yn 'Y'='Yes'
            'N'='No';
  value $area 'L'='Lakeside'
              'T'='Town Center'
              'N'='Northwest'
              'P'='Prairie';
  value yrslived 1='< 2'
                 2='2-10'
                 3='More than 10';
run;

proc report data=townsurvey nowindows

When sending output to the LISTING destination, underline all column headers and the spaces between them.
     headline;



  title 'Town Survey';
  title2 'Comments Received';

Select the observations to include in the report.
  where comments ne ' ';

  column area yrslived surveyid kids seniors
         comments;

Sort the detail rows by the order variables according to their position in the COLUMN statement, starting at the leftmost column and moving to the right. Specify the column width when sending output to the LISTING destination.
  define area     / order format=$area. width=12
                   'Residential/Area';
  define yrslived / order format=yrslived. width=12

Order the values by their unformatted values, which overrides the default ORDER=FORMATTED option.
                    order=internal
                    'Years/Lived in/Town'
                    left;

Suppress the display of SURVEYID, but use its values to order the rows. When sending output to the LISTING destination, also use SURVEYID in the BREAK AFTER statement to skip lines between each respondent’s comment.
  define surveyid / order noprint;

  define kids     / format=$yn. 'Children/Under 18?'
                    width=8 center;
  define seniors  / format=$yn. 'Adults/Over 65?'
                    width=8 center;

Wrap the values of this variable in its column.
  define comments / flow

Ensure that the column is wide enough when sending output to the LISTING destination.
                    width=35 'Comments';

Insert a blank line after each observation in the report when sending output to the LISTING destination.
  break after surveyid / skip;

Insert a blank line after the last observation in each area when sending output to the LISTING destination.
  break after area / skip;
run;


Where to Go from Here

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

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

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