29.12.2013 Views

Base SAS 9.1.3 Procedures Guide - Acsu Buffalo

Base SAS 9.1.3 Procedures Guide - Acsu Buffalo

Base SAS 9.1.3 Procedures Guide - Acsu Buffalo

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The REPORT Procedure 4 Program 987<br />

Specify the report options. The NOWD option runs PROC REPORT without the REPORT<br />

window and sends its output to the open output destination(s). NOHEADER in the PROC<br />

REPORT statement suppresses the default column headings.<br />

proc report data=grocery nowd<br />

headline headskip;<br />

Specify the title.<br />

title ’Sales for Individual Stores’;<br />

Specify the report columns. The report contains a column for Sector, Manager, Department,<br />

Sales, and Profit, but the NOPRINT option suppresses the printing of the columns for Sector and<br />

Manager. The page heading (created later in the program) includes their values. To get these<br />

variable values into the page heading, Sector and Manager must be in the COLUMN statement.<br />

column sector manager department sales Profit;<br />

Define the group, computed, and analysis variables. In this report, Sector, Manager, and<br />

Department are group variables. Each detail row of the report consolidates the information for<br />

all observations with the same values of the group variables. Profit is a computed variable<br />

whose values are calculated in the next section of the program. FORMAT= specifies the formats<br />

to use in the report.<br />

define sector / group noprint;<br />

define manager / group noprint;<br />

define profit / computed format=dollar11.2;<br />

define sales / analysis sum format=dollar11.2;<br />

define department / group format=$deptfmt.;<br />

Calculate the computed variable. Profit is computed as a percentage of Sales. For<br />

nonperishable items, the profit is 40% of the sale price. For perishable items the profit is 25%.<br />

Notice that in the compute block you must reference the variable Sales with a compound name<br />

(Sales.sum) that identifies both the variable and the statistic that you calculate with it.<br />

compute profit;<br />

if department=’np1’ or department=’np2’<br />

then profit=0.4*sales.sum;<br />

else profit=0.25*sales.sum;<br />

endcomp;<br />

Create a customized page header. This compute block executes at the top of each page, after<br />

PROC REPORT writes the title. It writes the page heading for the current manager’s store. The<br />

LEFT option left-justifies the text in the LINE statements. Each LINE statement writes the<br />

text in quotation marks just as it appears in the statement. The first two LINE statements<br />

write a variable value with the format specified immediately after the variable’s name.<br />

compute before _page_ / left;<br />

line sector $sctrfmt. ’ Sector’;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!