Sei sulla pagina 1di 30

Chapter 5 Creating Summarized

Output

5.1 Generating Summary Statistics ...................................................................................5-3


Demonstration: Generating Summary Statistics .................................................................... 5-5

Exercises ................................................................................................................................ 5-7

5.2 Creating a Summary Report with the Summary Tables Task ...................................5-10
Demonstration: Creating a Tabular Summary Report .......................................................... 5-11

Exercises .............................................................................................................................. 5-15

5.3 Solutions .....................................................................................................................5-18


Solutions to Exercises .......................................................................................................... 5-18
5-2 Chapter 5 Creating Summarized Output

Copyright © 2015, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
5.1 Generating Summary Statistics 5-3

5.1 Generating Summary Statistics


C op yr i g h t © 2 0 1 4 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

Objectives
 Create a summary table.
 Create a summary report.
 Export summary data to Excel.

C op yr i g h t © 2 0 1 4 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

Business Scenario
Management wants an HTML report and an Excel file
that include a summary of profits for each product line
and category.

Orion_Profit

Copyright © 2015, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
5-4 Chapter 5 Creating Summarized Output

C op yr i g h t © 2 0 1 4 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

Summary Statistics Task


The Summary Statistics task can be used to calculate
summary statistics based on groups within the data. You
can produce reports, graphs, and data sets as output.

C op yr i g h t © 2 0 1 4 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

Summary Statistics Task


The Summary Statistics task has both a wizard and a
standard task dialog box that can be used to set up results.

These options are available in Advanced View but not in the wizard:
 sorting by a classification variable
 applying a format to a classification variable
 including missing values in calculations
 specifying combinations of classification variables

 If you convert from the wizard to Advanced View, you cannot switch back to the wizard.

Copyright © 2015, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
5.1 Generating Summary Statistics 5-5

Generating Summary Statistics

Management wants a report that summarizes profits for each product line and category. Management
wants to be able to access an HTML report or an Excel file from a shared network drive.
1. Create a new project and add the orion_profit table.
2. To create the summary report and data set, select Describe  Summary Statistics Wizard
in the data grid.
3. In Step 1, you can verify the data and apply a filter if desired. Accept the default settings and click Next.
4. In Step 2, variables are assigned to task roles. Drag Profit into the Summary statistics of pane.
First, drag Product_Line into the For each value of pane, and then add Product_Category.
Click Next.

5. In Step 3, designate the statistics to include in the report. Click Edit.


a. On the Basic tab, clear Standard deviation, Minimum, Maximum, and Number of observations.
b. Select Sum.
c. Change the number of decimal places to 2.
d. Click the Percentile tab and select Median  OK.
6. Continuing in Step 3, select the Box and whisker check box to add a graph to the report.
7. Select the Save statistics to data set check box and click Browse. Enter profit_summary
in the File name field and select Save  Next.
8. In Step 4, delete the default analysis title and enter Summary of Profit by Product Line/Category.
Click Finish.

Copyright © 2015, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
5-6 Chapter 5 Creating Summarized Output

9. Notice the multiple tabs as part of the task results, including both the Results and Output Data tabs.
Partial Results

10. To create a more descriptive name for the task, right-click Summary Statistics in the project tree and
select Rename. Enter Profit by Product Summary.

11. To automate the export of the output data to Excel, click the Output Data tab. Select Export 
Export Summary Statistics for <libname>.ORION_PROFIT As A Step In Project.

12. In Step 1 of the Export Wizard, verify that Summary Statistics for <library>.ORION_PROFIT
is highlighted. Click Next.
13. In Step 2, select Microsoft Excel Workbooks (*.xlsx) as the output file type. Click Next.
14. In Step 3, select the Use labels for column names check box. Click Next.
15. In Step 4, change the name of the output file.
a. Click Browse and navigate to the location that is specified by your instructor.
b. Enter Profit_Summary in the File name field. Select Save.

 If you clear the Overwrite existing output check box and a file with the same name already
exists, then a new filename is created. The new filename appends the current date and time to
the existing filename.

Copyright © 2015, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
5.1 Generating Summary Statistics 5-7

16. Click Next to review the export settings and click Finish. The Profit_Summary.xlsx file
is exported and an Export File task is added to the project.

 If the project is rerun, both the Summary Statistics and Export File tasks run to update all results.

17. Save the project as Chapter5.

Exercises

Level 1

1. Creating a Summary Report of Salary by Department


Use the Summary Statistics Wizard to generate a report that analyzes the salaries of all employees
by Department.
a. In the Chapter5 project, add the employee_master table.
 If you do not have the Chapter5 project, you can create a new project.

b. Use the Summary Statistics Wizard to generate a report on the Salary column by Department.
c. Include the mean, minimum, maximum, and median salary for each group and round values
to the nearest dollar.
d. Create a SAS data set named salary_stats that includes the calculated statistics.
e. Enter Summary Statistics for Salary by Department as the title and delete the footnote.
f. Submit the task and view the report. Rename the task Salary by Dept Summary.
Partial Results

Copyright © 2015, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
5-8 Chapter 5 Creating Summarized Output

g. As a step in the project, export the output data to an Excel file named SalaryStats.xlsx.
h. Save the Chapter5 project.

Level 2

2. Creating a Summary Report of Salary by Department and State


Use the Summary Statistics task to create a report that summarizes employee salaries by department
and state.
a. In the Chapter5 project, add the employee_master table if necessary.
b. Use the Summary Statistics Wizard to summarize Salary by Department first, and then by State.
c. Include the mean, minimum, maximum, and median salary for each group and round values
to two decimal places.
d. Enter Summary Statistics for Salary by Department and State as the title and delete the
footnote.
e. Submit the task and view the report. Rename the task Salary by Dept, State Summary.
Partial Results

f. Modify the task to generate multiple reports for all combinations of the two classification
variables. In the project tree or process flow, right-click the Salary by Dept, State Summary
icon and select Open  Open in Advanced View to open the Summary Statistics task.
g. Select Results from the Selection pane. Select All ways in the Combinations of classification
variables drop-down list.
h. Submit the report. Click Yes when you are prompted to replace the results from the previous run.
Verify that four tables are included in the report, that is, one for each combination of the
classification variables.
i. Modify the task again to include only the second and third tables from the previous results.
Summarize Salary by Department first and Salary by State second. Run the task and replace
the results. Save the Chapter5 project.

Copyright © 2015, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
5.1 Generating Summary Statistics 5-9

Partial Results

Challenge

3. Modifying the Summary Statistics Task Code to Include an Additional Statistic


Insert custom code into the SAS program generated by the Summary Statistics task to calculate
the skewness statistic for employee salary by country.
a. In the Chapter5 project, add the employee_master table if necessary.
b. Use the Summary Statistics Wizard to create a report based on the employee_master table.
Rename the task Salary by Country Summary.
Partial Results

Copyright © 2015, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
5-10 Chapter 5 Creating Summarized Output

c. Reopen the task in Advanced View and modify the underlying code in the Salary by Country
Summary task to add the skewness statistics in the report. Add the SKEWNESS keyword directly
after other listed statistics.

 Skewness is a measure that indicates to what degree the distribution of data values has
a longer tail to the left or to the right. For the salary distribution for both US and AU,
there are a few extreme values at the high end and a concentration of values at the low
end of the distribution, so the right tail of the distribution curve is longer (right-skewed).
For such data, the skewness statistic is greater than zero. If the data is left-skewed, the
skewness statistic is less than zero.
d. Run the task and replace the results. Verify that the additional skewness statistic was added to the
report. Save the Chapter5 project.

5.2 Creating a Summary Report with the


Summary Tables Task
C op yr i g h t © 2 0 1 4 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

Objectives
 Access the Summary Tables task.
 Specify a table layout and statistics.
 Define headings for columns and rows.
 Assign a label for missing values.
 Add titles to the report.
 Generate the tabular summary report.

12

Copyright © 2015, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
5.2 Creating a Summary Report with the Summary Tables Task 5-11

C op yr i g h t © 2 0 1 4 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

Business Scenario
To better understand customer purchasing, the Orion
marketing group requested a report that summarizes total
profits for each customer age group and product category.

13

C op yr i g h t © 2 0 1 4 , S A S I n s t i t u t e I n c . A l l r i g h t s r es er v e d .

Summary Tables
The Summary Tables Wizard or task can be used
to generate a tabular summary report.

14

Creating a Tabular Summary Report

Using the orion_profit table, create a tabular summary report to display the sum of profit for each
product category and customer age group.

Copyright © 2015, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
5-12 Chapter 5 Creating Summarized Output

1. In the Chapter5 project, double-click the orion_profit icon in the project tree or process flow
to open it in the data grid.
2. Select Describe  Summary Tables Wizard from the data grid.
3. In Step 1, verify that the active data source is the orion_profit table. Click Next.
4. In Step 2, analysis variables and statistics are assigned. To calculate the sum of profit, select
Add  Profit.
5. To apply a format so that the values in the table appear as currency values, click Browse.
Select Currency from the Categories pane and DOLLARw.d from the Formats pane. Change
the overall width to 8 and leave the number of decimal places as 0. Click OK  Next.

6. In Step 3, classification variables are assigned to define the rows and columns of the table. Select
Add  Customer_Age_Group in the Columns pane, and select Add  Product_Category
in the Rows pane. Click Next.

7. In Step 4, verify that Grand total only is selected for both rows and columns. Click Next.

Copyright © 2015, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
5.2 Creating a Summary Report with the Summary Tables Task 5-13

8. Click Next twice to proceed through the final two steps. Click Finish to view the intermediate results.

9. Further modifications can be made to improve the display of the report in the Summary Tables
Wizard. On the Results tab, select Modify Task to reopen the wizard.
10. To delete the Profit and Sum headings, click Next to advance to Step 2. Change the value in the
Analysis variable labels and Statistics labels fields to hidden.
11. Click Next to advance to Step 3. To group Product_Category by Product_Line, select Add 
Product_Line in the Rows box. Select Product_Line and click to move it to the top of the list.

12. To delete the labels for Product_Category, Product_Line, and the extra blank space that is included
in the first row of the table, select More Options. Click the Hide the row headers check box.
Click OK  Next.
13. To add subtotals for each value of Product_Line, change the value in the Rows field to Totals at
each level.
14. Click Finish. When you are prompted to replace the results, click Yes.

15. To further modify the appearance of the table, the Advanced View of the Summary Tables task must
be used. Right-click the Summary Tables Wizard icon in the project tree or process flow.
Select Open  Open in Advanced View.

Copyright © 2015, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
5-14 Chapter 5 Creating Summarized Output

16. Select Summary Tables in the Selection pane. To change the column heading for
Customer_Age_Group, right-click Customer_Age_Group in the Preview area and select
Heading Properties.

17. In the Heading Properties window, enter Profit by Customer Age Group in the Label field. Click
OK.

 If you delete a label entirely, the box is also removed from the final report.
18. Change the column heading for the Product_Line subtotals by right-clicking the Total label
and selecting Heading Properties.

19. Enter Product Line Subtotal in the Label field. Click OK.
20. To highlight the subtotals with a different color background and font, right-click Total (the subtotals
for Product_Line) and select Data Value Properties.
21. In the Data Value Properties window, click the Font tab. Select the Bold Italic font style and light
yellow for the background color. Click OK.
22. To highlight the grand total row, right-click Total (the last row of the report) and select Heading
Properties. On the Font tab, select the Bold font style and 3 for the size. Click OK.
23. Right-click Total again and select Data Value Properties. On the Font tab, select the Bold font style
and 3 for the size. Click OK.

Copyright © 2015, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
5.2 Creating a Summary Report with the Summary Tables Task 5-15

24. To specify a label for missing values, right-click anywhere on the table and select Table Properties.
25. In the Table Properties window, click the General tab. Delete the default label in the Label for
missing values field and enter **. Click OK.
26. Click Run to generate the final report. Click Yes when you are prompted to replace the results.

27. Save the Chapter5 project.

Exercises

Level 1

4. Creating a Summary Tables Report with Multiple Statistics


Use the Summary Tables task to generate a report that displays the minimum and maximum salary
for each country and department.
a. In the Chapter5 project, add the employee_master table if necessary.
 If you do not have the Chapter5 project, you can create a new project.
b. Open the Summary Tables Wizard. In Step 2, add Salary to the Analysis variables list two times.
Select Minimum for the first statistic and Maximum for the second.
c. Hide the analysis variable labels and apply the DOLLARw.d format to the table with 10
for the overall width and 0 for the decimal places.
d. Add Country in the Columns pane and Department in the Rows pane. Hide the row headings.
e. Eliminate the totals for both the rows and columns.
f. Generate the report and examine the results.

Copyright © 2015, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
5-16 Chapter 5 Creating Summarized Output

g. Modify the Summary Tables task by opening it in Advanced View. Modify the heading properties
for the Minimum and Maximum columns to display Low and High.
h. Modify the heading properties for Country to display Salary Ranges by Country.
i. Modify the table properties to display missing values as a single hyphen.
j. Change the task label to Salary Ranges by Country.
k. Generate the report and save the Chapter5 project.

Level 2

5. Creating a Summary Tables Report with Multiple Statistics and Highlighting


Use the Summary Tables task to generate a report that displays the frequency, percent of column
frequency, and percent of column sum by department for each city in Australia.
a. In the Chapter5 project, open the employee_master table and the Summary Tables Wizard.
b. Edit the data so that only employees from Australia are included in the report.
c. Add the Salary variable as the analysis variable three times. Select the first statistic as
Frequency, the second statistic as % of Column Frequency, and the third statistic as
% of Column Sum. Hide the analysis variable label.
d. Add City as the column classification variable and Department as the row classification variable.
Hide the row and column headings.
e. Enter Summary of Salaries for Australia by Department as the title and delete the footnote.
Submit the task and view the report.

Copyright © 2015, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
5.2 Creating a Summary Report with the Summary Tables Task 5-17

f. Modify the report by opening the task in Advanced View. Use the Summary Tables preview
to delete ColPctN from the Total column.
Hint: Delete Salary first and then delete ColPctN.
g. Modify the headings to match the final output below. Change the background color of the data
values in the Total row and Total column to light orange.
h. Change the task label to AU Salary Report. Generate the report and save the Chapter5 project.

Challenge

6. Creating and Applying a Custom Percentage Format


You might want to display a percent sign (%) after the percentage values in your table created by the
Summary Tables task. If you use the PERCENTw.d format, it multiplies data values by 100, and then
adds a percent sign (%) to the end of the formatted value. The Summary Tables task already
multiplied the values by 100 to compute the percent. Therefore, if you use the PERCENTw.d format
to format the values, they are incorrect. Because you do not want the value multiplied by 100, you
need to create a picture format. Use PROC FORMAT to add the percent sign to the value.
a. Complete the Level 2 exercise.
b. Open and run the e105e06 SAS program. This program creates a user-defined format named
MYPCT that rounds values to the nearest tenth and adds a percent sign.
c. Modify AU Salary Report, which was created in the Level 2 exercise. Apply the MYPCT format
by modifying the data value properties for all percentage columns in the report.
 Look for the User Defined category in the Format window.

Copyright © 2015, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
5-18 Chapter 5 Creating Summarized Output

d. Generate the report and save the Chapter5 project.

5.3 Solutions
Solutions to Exercises
1. Creating a Summary Report of Salary by Department
Use the Summary Statistics Wizard to generate a report that analyzes the salaries of all employees
by Department.
a. In the Chapter5 project, add the employee_master table.

 If you do not have the Chapter5 project, you can create a new project.

1) If you need to create a new project, select File  New  Project.


2) Select File  Open  Data and navigate to the location of the course data.
3) Select employee_master  Open.
b. Use the Summary Statistics Wizard to generate a report on the Salary column by Department.
1) In the data grid, select Describe  Summary Statistics Wizard.
2) In Step 1, verify that the data being processed is employee_master. Click Next.
3) In Step 2, drag the Salary column to the Summary statistics of pane and the Department
column to the For each value of pane. Click Next.
c. Include the mean, minimum, maximum, and median salary for each group and round values
to the nearest dollar.
1) In Step 3, click Edit to open the Edit Statistics window. On the Basic tab, clear the Standard
deviation and Number of observations check boxes. Use the drop-down box to select 0 for
the number of decimal places.
2) Click the Percentile tab and select the Median statistic. Click OK to close the Edit Statistics
window.
d. Create a SAS data set named salary_stats that includes the calculated statistics.
1) In Step 3, select the Save statistics to data set check box.

Copyright © 2015, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
5.3 Solutions 5-19

2) Click Browse.
3) Enter salary_stats in the File name field and select Save.
4) Click Next.
e. Enter Summary Statistics for Salary by Department as the title and delete the footnote.
In Step 4, add the title Summary Statistics for Salary by Department in the Analysis pane,
and delete the footnote.
f. Submit the task and view the report. Rename the task Salary by Dept Summary.
1) Click Finish. In the project tree, right-click the Summary Statistics Wizard icon and select
Properties.
2) Change the label to Salary by Department Summary. Click OK to close the Properties
window.
Partial Results

g. As a step in the project, export the output data to an Excel file named SalaryStats.xlsx.
1) Click the Output Data tab.
2) Select Export  Export Summary Statistics for <libname>.EMPLOYEE_MASTER
As A Step In Project.
3) In the Export Wizard, click Next to advance to Step 2.
4) In Step 2, select Microsoft Excel Workbooks (*.xlsx). Click Next.
5) In Step 3, select the Use labels for column names check box. Click Next.
6) In Step 4, click Browse and navigate to the location that is indicated by your instructor.
7) Enter SalaryStats in the File name field and select Save. Click Next.
8) In Step 5, verify the selections and click Finish.
h. Save the Chapter5 project.
1) Click on the toolbar.

Copyright © 2015, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
5-20 Chapter 5 Creating Summarized Output

2) If the Save window appears, navigate to the location that is specified by your instructor.
Enter Chapter5 in the File name field and select Save.
2. Creating a Summary Report of Salary by Department and State
Use the Summary Statistics task to create a report that summarizes employee salaries by department
and state.
a. In the Chapter5 project, add the employee_master table if necessary.
1) Select File  Open  Data and navigate to the location of the course data.
2) Select employee_master  Open.
b. Use the Summary Statistics Wizard to summarize Salary by Department first, and then by State.
1) In the data grid, select Describe  Summary Statistics Wizard.
2) In Step 1, verify that the data being processed is employee_master and click Next.
3) In Step 2, drag the Salary column to the Summary statistics of pane and the Department
and State columns to the For each value of pane. Click Next.
c. Include the mean, minimum, maximum, and median salary for each group and round values
to two decimal places.
1) In Step 3, click Edit to open the Edit Statistics window. On the Basic tab, clear the
Standard deviation and Number of Observations check boxes. Use the drop-down box
to select 2 for the number of decimal places.
2) Click the Percentile tab and select the Median statistic. Click OK to close the Edit Statistics
window.
3) Click Next.
d. Enter Summary Statistics for Salary by Department and State as the title and delete
the footnote.
In Step 4, add the title Summary Statistics for Salary by Department and State
in the Analysis pane, and delete the footnote.
e. Submit the task and view the report. Rename the task Salary by Dept, State Summary.
1) Click Finish and review the results.
2) In the project tree or process flow, right-click the Summary Statistics Wizard icon and select
Properties.
3) Change the label to Salary by Dept, State Summary. Click OK to close the Properties window.

Copyright © 2015, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
5.3 Solutions 5-21

Partial Results

f. Modify the task to generate multiple reports for all combinations of the two classification
variables. In the project tree or process flow, right-click the Salary by Dept, State Summary
icon and select Open  Open in Advanced View to open the Summary Statistics task.
g. Select Results from the Selection pane. Select All ways in the Combinations of classification
variables drop-down list.
h. Submit the report. Click Yes when you are prompted to replace the results from the previous run.
Verify that four tables are included in the report, that is, one for each combination of the
classification variables.
Click Run  Yes.
i. Modify the task again to include only the second and third tables from the previous results.
Summarize Salary by Department first and Salary by State second. Run the task and replace
the results. Save the Chapter5 project.
1) In the Results window, click the Modify Task button to reopen the task.
2) Select the Results pane.
3) Use the Combination of classification variables drop-down box to select Specify ways.
In the Specify ways box, enter 1.
4) Click Run  Yes when you are prompted to replace the results.
5) Click on the toolbar.

6) If the Save window appears, navigate to the location that is specified by your instructor.
Enter Chapter5 in the File name field and select Save.

Copyright © 2015, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
5-22 Chapter 5 Creating Summarized Output

Partial Results

3. Modifying the Summary Statistics Task Code to Include an Additional Statistic


Insert custom code in the SAS program generated by the Summary Statistics task to calculate
the skewness statistic for employee salary by country.
a. In the Chapter5 project, add the employee_master table if necessary.
1) Select File  Open  Data and navigate to the location of the course data.
2) Select employee_master  Open.
b. Use the Summary Statistics Wizard to create a report based on the employee_master table.
Rename the task Salary by Country Summary.
1) In the data grid, select Describe  Summary Statistics Wizard.
2) In Step 1, verify that the data being processed is employee_master and click Next.
3) In Step 2, drag the Salary column to the Summary statistics of pane and the Country column
to the For each value of pane. Click Next.
4) In Step 3, click Edit to open the Edit Statistics window. On the Basic tab, use the drop-down
box to select 2 for the number of decimal places. Click OK to close the Edit Statistics
window. Select the Histogram check box. Click Next.
5) In Step 4, enter the title Salary by Country Summary in the Analysis pane. Delete the
histogram title and footnote.
6) Click Finish and view the report.
7) Right-click Summary Statistics under EMPLOYEE_MASTER in the project tree and select
Rename. Enter Salary by Country Summary.

Copyright © 2015, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
5.3 Solutions 5-23

Partial Results

c. Reopen the task in Advanced View and modify the underlying code in the Salary by Country
Summary task to add the skewness statistics in the report. Add the SKEWNESS keyword directly
after other statistics listed.
1) Right-click the Salary by Country Summary task in the project tree or process flow and
select Open  Open in Advanced View.
2) Select Preview Code and select the Show custom code insertion points check box.
3) Scroll down to find the end of the PROC MEANS statement. Click to insert custom code
between the N option and the semicolon. Enter skewness.
4) Close the Code Preview window.
d. Run the task and replace the results. Verify that the additional skewness statistic was added
to the report. Save the Chapter5 project.
1) Click Run  Yes.
2) Click on the toolbar.

3) If the Save window appears, navigate to the location that is specified by your instructor.
Enter Chapter5 in the File name field and select Save.

Copyright © 2015, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
5-24 Chapter 5 Creating Summarized Output

4. Creating a Summary Tables Report with Multiple Statistics


Use the Summary Tables task to generate a report calculating the minimum and maximum salary
for each country and department.
a. In the Chapter5 project, add the employee_master table.

 If you do not have the Chapter5 project, you can create a new project.
1) Select File  Open  Data and navigate to the location of the course data.
2) Select employee_master  Open.
b. Open the Summary Tables Wizard. In Step 2, add Salary to the Analysis variables list two times.
Select Minimum for the first statistic and Maximum for the second.
1) In the project tree or process flow, double-click the employee_master table to open the data
grid. Select Describe  Summary Tables Wizard.
2) In Step 1 of the wizard, confirm that the employee_master table is being processed. Click Next.
3) In Step 2, click Add and select Salary from the list. Repeat these steps so that Salary is listed
twice. Notice at this point that the statistic for both lines is Sum.
4) Click the Statistic column for the first Salary row. Use the drop-down menu to select
the Minimum statistic.
5) Click the Statistic column for the second Salary row. Use the drop-down menu to select
the Maximum statistic.
c. Hide the analysis variable labels and apply the DOLLARw.d format to the table with 10
for the overall width and 0 for the decimal places.
1) For the Analysis variable labels, use the drop-down menu to select hidden.
2) Click Browse to open the Select Column Format window. Select the Currency category
and select the DOLLARw.d format. Use the spin boxes to set the overall width to 10 and
the decimal places to 0. Click OK to close the Select Column Format window. Click Next.
d. Add Country in the Columns pane and Department in the Rows pane. Hide the row headings.
1) In Step 3, click Add for the Columns section and select the Country column from the list.
2) Click Add in the Rows section and select the Department column from the list.
3) Select More Options and select the Hide the row headers check box. Click OK to close
the More Options window.
4) Click Next.
e. Eliminate the totals for both the rows and columns.
In Step 4, for both the column and row totals, use the drop-down menu to select None.
f. Generate the report and examine the results.
Click Finish.

Copyright © 2015, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
5.3 Solutions 5-25

g. Modify the Summary Tables task by opening it in Advanced View. Modify the heading properties
for the Minimum and Maximum columns to display Low and High.
1) In the project tree or process flow, right-click the Summary Tables icon under the
employee_master table and select Open  Open in Advanced View.
2) Select the Summary Tables pane.
3) Right-click either of the Min statistics headings and select Heading Properties. In the Heading
Properties for Min window, enter Low in the Label field. Click OK to close the window.
4) Right-click either of the Max statistics headings and select Heading Properties. In the Heading
Properties for Max window, enter High in the Label field. Click OK to close the window.
h. Modify the heading properties for Country to display Salary Ranges by Country.
1) Right-click the Country heading and select Heading Properties.
2) In the Heading Properties for Country window, enter Salary Ranges by Country in the Label
field. Click OK to close the window.
i. Modify the table properties to display missing values as a single hyphen.
1) Right-click in the table and select Table Properties.
2) In the Table properties window, delete the period and enter a hyphen (-) in the Label for
missing value field. Click OK to close the window.
j. Change the task label to Salary Ranges by Country.
1) Select Properties in the Selection pane and click Edit.
2) Enter Salary Ranges by Country in the Label field and click OK.
k. Generate the report and save the Chapter5 project.
1) Click Run. Click Yes when you are prompted to replace the results. View the updated report.

Copyright © 2015, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
5-26 Chapter 5 Creating Summarized Output

2) Click on the toolbar.

3) If the Save window appears, navigate to the location that is specified by your instructor.
Enter Chapter5 in the File name field and select Save.
5. Creating a Summary Tables Report with Multiple Statistics and Highlighting
Use the Summary Tables task to generate a report that calculates the frequency, percent of column
frequency, and percent of column sum by department for each city in Australia.
a. In the Chapter5 project, open the employee_master table and the Summary Tables Wizard.
1) In the project tree or process flow, double-click the employee_master table to open
the data grid.
2) Select Describe  Summary Tables Wizard.
b. Edit the data so that only employees from Australia are included in the report.
1) In Step 1 of the wizard, confirm that the employee_master table is being processed.
Click Edit.
2) In the first field of the Edit Data and Filter window, use the drop-down menu to select
the Country column.
3) In the second field, use the drop-down menu to select Equal to. In the third field, click .
Select AU and click OK twice.
4) Click Next.
c. Add the Salary variable as the analysis variable three times. Select the first statistic as
Frequency, the second statistic as % of Column Frequency, and the third statistic as
% of Column Sum. Hide the analysis variable label.
1) In Step 2, click Add and select Salary from the list. Repeat these steps twice so that Salary
is listed three times. Notice at this point that the statistic for all lines is Sum.
a) Click in the statistic column for the first Salary row. Use the drop-down menu to select
the Frequency statistic.
b) Click in the statistic column for the second Salary row. Use the drop-down menu to select
the % of Column Frequency statistic.

Copyright © 2015, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
5.3 Solutions 5-27

c) Click in the statistic column for the second Salary row. Use the drop-down menu to select
the % of Column Sum statistic.
2) In the Analysis variable labels field, use the drop-down menu to select hidden.
3) Click Next.
d. Add City as the column classification variable and Department as the row classification variable.
Hide the row and column headings.
1) In Step 3, click Add for the Columns section and select the City column from the list.
2) Click Add in the Rows section and select the Department column from the list.
3) Click the More Options button. Select the Hide the row headers and the Hide the column
headers check boxes. Click OK to close the More Options window.
4) Click Next three times to move to Step 6 of the wizard.
e. Enter Summary of Salaries for Australia by Department as the title and delete the footnote.
Submit the task and view the report.
1) In Step 6, delete the current text in the Table Titles field, and enter Summary of Salaries
for Australia by Department.
2) Delete the text in the Footnote field.
3) Click Finish and view the report.

f. Modify the report by opening the task in Advanced View. Use the Summary Tables preview
to delete ColPctN from the Total column.
Hint: Delete Salary first and then delete ColPctN.
1) In the project tree or process flow, right-click the Summary Tables icon under
the employee_master table. Select Open  Open in Advanced View.
2) Select the Summary Tables pane.
3) In the Total column, right-click the Salary cell above the ColPctN statistic and select
Remove Cells. Right-click the ColPctN statistic and select Remove Cells. This deletes
% of Column Frequency from the Total column.

Copyright © 2015, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
5-28 Chapter 5 Creating Summarized Output

4) Right-click the ColPctSum statistic under the Total column, and select Heading Properties.
Enter Percent of Total Salaries in the Label field. Click OK.
g. Modify the headings to match the final output below. Change the background color of the data
values in the Total row and Total column to light orange.
1) Right-click either N statistic under the city variable, and select Heading Properties.
Enter Employee Count in the Label field. Click OK.
2) Right-click either ColPctN statistic under the city variable, and select Heading Properties.
Enter Percent of Employees in the Label field. Click OK.
3) Right-click either ColPctSum statistic under the city variable, and select Heading Properties.
Enter Percent of Salaries in the Label field. Click OK.
4) Right-click the N statistic under the Total column, and select Heading Properties.
Enter Total Employees in the Label field. Click OK.
5) Select the column Total heading. Right-click and select Data Value Properties. In the Data
Values Properties for All window, click the Font tab. Use the drop-down menu for the
Background color to select Light Orange. Click OK.
6) Select the row Total heading. Right-click and select Data Value Properties. In the Data
Values Properties for All window, click the Font tab. Use the drop-down menu for
the Background color to select Light Orange. Click OK.
h. Change the task label to AU Salary Report. Generate the report and save the Chapter5 project.
1) Select Properties in the Selection pane and click Edit.
2) Enter AU Salary Report in the Label field and click OK.
3) Click Run  Yes when you are prompted to replace the results.
4) Click on the toolbar.
5) If the Save window appears, navigate to the location that is specified by your instructor.
Enter Chapter5 in the File name field and select Save.

Copyright © 2015, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
5.3 Solutions 5-29

6. Creating and Applying a Custom Percentage Format


You might want to display a percent sign (%) after the percentage values in your table created
by the Summary Tables task. If you use the PERCENTw.d format, it multiplies data values by 100,
and then adds a percent sign (%) to the end of the formatted value. The Summary Tables task already
multiplied the values by 100 to compute the percent. Therefore, if you use the PERCENTw.d format
to format the values, they are incorrect. Because you do not want the value multiplied by 100, you
need to create a picture format. Use PROC FORMAT to add the percent sign to the value.
a. Complete the Level 2 exercise.
Refer to the solutions for the previous exercise.
b. Open and run the e105e06 SAS program. This program creates a user-defined format named
MYPCT that rounds values to the nearest tenth and adds a percent sign.
1) Select File  Open  Program.
2) Navigate to the location of the course data and select e105e06  Open.
3) On the Program tab, click Run.
c. Modify AU Salary Report, which was created in the Level 2 exercise. Apply the MYPCT format
by modifying the data value properties for all percentage columns in the report.

 Look for the User Defined category in the Format window.


1) Right-click the AU Salary Report task that was produced in the previous exercise and select
Modify Summary Tables.
2) Select Summary Tables.
3) Right-click each ColPctN and ColPctSum column and select Data Value Properties.
4) Click the Format tab and the User Defined category. Highlight the MYPCT. format. Click OK.
d. Generate the report and save the Chapter5 project.
1) Click Run  Yes when you are prompted to replace the results. View the updated report.

2) Click on the toolbar.

3) If the Save window appears, navigate to the location that is specified by your instructor.
Enter Chapter5 in the File name field and select Save.

Copyright © 2015, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.
5-30 Chapter 5 Creating Summarized Output

Copyright © 2015, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED.

Potrebbero piacerti anche