Previous Page | Next Page

The PRINT Procedure

Example 7: Controlling the Layout of a Report with Many Variables


Procedure features:

PROC PRINT statement options:

ROWS=

ID statement options:

STYLE

Other features:

ODS RTF statement

SAS data set options:

OBS=

Data set: EMPDATA

This example shows two ways of printing a data set with a large number of variables: one is the default, printing multiple rows when there are a large number of variables, and the other uses ROWS= option to print one row. For detailed explanations of the layouts of these two reports, see the ROWS= option and see Page Layout.

These reports use a page size of 24 and a line size of 64 to help illustrate the different layouts.

Note:   When the two reports are written as HTML output, they do not differ.  [cautionend]


Program: Creating a Listing Report

 Note about code
data empdata;
   input IdNumber $ 1-4 LastName $ 9-19 FirstName $ 20-29 
         City $ 30-42 State $ 43-44 /
         Gender $ 1 JobCode $ 9-11 Salary 20-29 @30 Birth date9.
         @43 Hired date9. HomePhone $ 54-65;
   format birth hired date9.;
   datalines;
1919    Adams      Gerald    Stamford     CT
M       TA2        34376     15SEP1970      07JUN2005    203/781-1255
1653    Alexander  Susan     Bridgeport   CT
F       ME2        35108     18OCT1972      12AUG1998    203/675-7715
           
. . . more lines
of data . . .
           
1407    Grant      Daniel    Mt. Vernon   NY
M       PT1        68096     26MAR1977      21MAR1998    914/468-1616
1114    Green      Janice    New York     NY
F       TA2        32928     21SEP1977      30JUN2006    212/588-1092
;
 Note about code
proc print data=empdata(obs=12);
   id idnumber;
   title 'Personnel Data';
run;
 Note about code
proc print data=empdata(obs=12) rows=page;
   id idnumber;
   title 'Personnel Data';
run;

Output: Listing

Default Layout for a Report with Many Variables: Listing Output

 Note about figure
                         Personnel Data                        1

    Id               First                                Job
  Number  LastName   Name         City     State  Gender  Code

   1919   Adams      Gerald    Stamford     CT      M     TA2 
   1653   Alexander  Susan     Bridgeport   CT      F     ME2 
   1400   Apple      Troy      New York     NY      M     ME1 
   1350   Arthur     Barbara   New York     NY      F     FA3 
   1401   Avery      Jerry     Paterson     NJ      M     TA3 
   1499   Barefoot   Joseph    Princeton    NJ      M     ME3 
   1101   Baucom     Walter    New York     NY      M     SCP 

    Id
  Number  Salary        Birth        Hired     HomePhone

   1919    34376    15SEP1970    07JUN2005    203/781-1255
   1653    35108    18OCT1982    12AUG1998    203/675-7715
   1400    29769    08NOV1985    19OCT2006    212/586-0808
   1350    32886    03SEP1963    01AUG2000    718/383-1549
   1401    38822    16DEC1968    20NOV1993    201/732-8787
   1499    43025    29APR1962    10JUN1995    201/812-5665
   1101    18723    09JUN1980    04OCT1998    212/586-8060
                         Personnel Data                        2

    Id               First                                Job
  Number  LastName   Name         City     State  Gender  Code

   1333   Blair      Justin    Stamford     CT      M     PT2 
   1402   Blalock    Ralph     New York     NY      M     TA2 
   1479   Bostic     Marie     New York     NY      F     TA3 
   1403   Bowden     Earl      Bridgeport   CT      M     ME1 
   1739   Boyce      Jonathan  New York     NY      M     PT1 

    Id
  Number  Salary        Birth        Hired     HomePhone

   1333    88606    02APR1979    13FEB2003    203/781-1777
   1402    32615    20JAN1971    05DEC1998    718/384-2849
   1479    38785    25DEC1966    08OCT2003    718/384-8816
   1403    28072    31JAN1979    24DEC1999    203/675-3434
   1739    66517    28DEC1982    30JAN2000    212/587-1247

Layout Produced by the ROWS=PAGE Option: Listing Output

 Note about figure
                         Personnel Data                        1

    Id               First                                Job
  Number  LastName   Name         City     State  Gender  Code

   1919   Adams      Gerald    Stamford     CT      M     TA2 
   1653   Alexander  Susan     Bridgeport   CT      F     ME2 
   1400   Apple      Troy      New York     NY      M     ME1 
   1350   Arthur     Barbara   New York     NY      F     FA3 
   1401   Avery      Jerry     Paterson     NJ      M     TA3 
   1499   Barefoot   Joseph    Princeton    NJ      M     ME3 
   1101   Baucom     Walter    New York     NY      M     SCP 
   1333   Blair      Justin    Stamford     CT      M     PT2 
   1402   Blalock    Ralph     New York     NY      M     TA2 
   1479   Bostic     Marie     New York     NY      F     TA3 
   1403   Bowden     Earl      Bridgeport   CT      M     ME1 
   1739   Boyce      Jonathan  New York     NY      M     PT1 
                         Personnel Data                        2

    Id
  Number  Salary        Birth        Hired     HomePhone

   1919    34376    15SEP1970    07JUN2005    203/781-1255
   1653    35108    18OCT1982    12AUG1998    203/675-7715
   1400    29769    08NOV1985    19OCT2006    212/586-0808
   1350    32886    03SEP1963    01AUG2000    718/383-1549
   1401    38822    16DEC1968    20NOV1993    201/732-8787
   1499    43025    29APR1962    10JUN1995    201/812-5665
   1101    18723    09JUN1980    04OCT1998    212/586-8060
   1333    88606    02APR1979    13FEB2003    203/781-1777
   1402    32615    20JAN1971    05DEC1998    718/384-2849
   1479    38785    25DEC1966    08OCT2003    718/384-8816
   1403    28072    31JAN1979    24DEC1999    203/675-3434
   1739    66517    28DEC1982    30JAN2000    212/587-1247

Program: Creating an RTF Report

options nodate pageno=1 linesize=64 pagesize=24;

 Note about code
ods rtf file='your_file.rtf';
proc print data=empdata(obs=12);
   id idnumber;
   title 'Personnel Data';
run;

 Note about code
ods rtf close;

Output: RTF

Layout for a Report with Many Variables: RTF Output

[Layout for a Report with Many Variables: RTF Output]


Program: Creating an RTF Report with the STYLE Option

options nodate pageno=1 linesize=64 pagesize=24;

ods rtf file='your_file.rtf';

proc print data=empdata(obs=12);
   

 Note about code
id idnumber / style(DATA) = 
            {background = red foreground = white}
            style(HEADER) = 
            {background = blue foreground = white};  
   title 'Personnel Data';
run;

ods rtf close;


Output: RTF with Styles

Layout for a Report with Many Variables: RTF Output Using Styles

[Layout for a Report with Many Variables: RTF Output Using Styles]

Previous Page | Next Page | Top of Page