Escolar Documentos
Profissional Documentos
Cultura Documentos
re
di
st
rib
SA
op
yr
ig
ht
ed
-D
no
t
12-2
ut
e
Exercises
rib
Level 1
re
di
st
1) Display the number of distinct levels of Customer_ID and Employee_ID for retail
orders.
no
t
a) Use a WHERE statement to limit the report to retail sales by specifying the condition
Order_Type=1.
If you do not want to see the counts for individual levels of Customer_ID
and Employee_ID, add the NOPRINT option to the TABLES statement after
a forward slash.
-D
2) Display the number of distinct levels for Customer_ID for catalog and Internet orders.
ed
a) Use a WHERE statement to limit the report to catalog and Internet sales by specifying
the condition corresponding to Order_Type values other than 1.
If you do not want to see the counts for individual levels of Customer_ID,
add the NOPRINT option to the TABLES statement after a forward slash.
SA
op
yr
ig
ht
b) Display this report title: Unique Customers for Catalog and Internet.
12-3
ut
e
Uni que Cust omer s and Sal esper sons f or Ret ai l Sal es
The FREQ Pr ocedur e
re
di
st
Var i abl e
Label
Level s
Cust omer _I D
Cust omer I D
31
Empl oyee_I D
Empl oy ee I D
100
rib
no
t
Var i abl e
Label
Level s
Cust omer _I D
Cust omer I D
63
-D
Level 2
ed
b. Add TABLES statements to the PROC FREQ step to produce three frequency reports:
ht
1) Number of orders in each year: Apply the YEAR4. format to the Order_Date variable to
combine all orders within the same year.
yr
ig
2) Number of orders of each order type: Apply the ordertypes. format defined in the starter
program to the Order_Type variable. Suppress the cumulative frequency and percentages.
SA
op
3) Number of orders for each combination of year and order type: Suppress all percentages that
normally appear in each cell of an n-way table.
12-4
ut
e
rib
re
di
st
Cumul at i ve
Cumul at i ve
Or der _Dat e
Fr equency
Per cent
Fr equency
Per c ent
2003
104
21. 22
104
21. 22
2004
87
17. 76
191
38. 98
2005
70
14. 29
261
53. 27
2006
113
23. 06
374
76. 33
2007
116
23. 67
490
100. 00
no
t
Or der Type
-D
Or der _
Type
Fr equency
Per c ent
Ret ai l
260
53. 06
Cat al og
132
26. 94
I nt er net
98
20. 00
ed
SA
op
yr
ig
ht
Fr equency Ret ai l
Cat al og I nt er net
2003
45
41
18
2004
51
20
16
2005
27
23
20
2006
67
33
13
2007
70
15
31
Tot al
260
132
98
Tot al
104
87
70
113
116
490
12-5
Level 3
ut
e
rib
re
di
st
-D
no
t
Cust omer _
Cumul at i ve
Cumul at i ve
Count r y
Fr equency
Per cent
Fr equency
Per c ent
AU
8
10. 39
8
10. 39
CA
15
19. 48
23
29. 87
DE
10
12. 99
33
42. 86
IL
5
6. 49
38
49. 35
TR
7
9. 09
45
58. 44
US
28
36. 36
73
94. 81
ZA
4
5. 19
77
100. 00
SA
op
yr
ig
ht
ed
Cumul at i ve
Cumul at i v e
Cust omer _Type
Fr equency
Per cent
Fr equency
Per cent
Cust omer _
Cumul at i ve
Cumul at i ve
Age_Gr oup
Fr equency
Per cent
Fr equency
Per cent
15- 30 year s
22
28. 57
22
28. 57
31- 45 year s
27
35. 06
49
63. 64
46- 60 year s
14
18. 18
63
81. 82
61- 75 year s
14
18. 18
77
100. 00
12-6
___________________
____________________
2) Customer Type
___________________
____________________
____________________
rib
1) Country
ut
e
c. What are the two most common values for each variable?
no
t
f. What are the two most common values for each variable?
re
di
st
Documentation about the FREQ procedure can be found in the SAS Help and
Documentation from the Contents tab (SAS Products Base SAS
Base SAS Procedures Guide: Statistical Procedures The FREQ Procedure).
Look for an option in the PROC FREQ statement that can perform the requested
action.
___________________
____________________
2) Customer Type
___________________
____________________
____________________
1) Country
-D
ed
ht
b. Create an output data set containing the frequency counts based on Product_ID.
Creating an output data set from PROC FREQ results is discussed in the self-study
content at the end of this section.
yr
ig
op
c. Combine the output data set with orion.product_list to obtain the Product_Name
value for each Product_ID code.
d. Sort the merged data so that the most frequently ordered products appear at the top of the
resulting data set. Print the first 10 observations, that is, those that represent the 10 products
ordered most often.
SA
12-7
230100500056
230100600030
230100600022
240400300035
230100500082
230100600005
230100600016
230100600028
230100700008
230100700011
rib
6
6
5
5
4
4
4
4
4
4
Pr oduct
Kni f e
Out back Sl eepi ng Bag, Lar ge, Lef t , Bl ue/ Bl ack
Expedi t i on10, Medi um, Ri ght , Bl ue Ri bbon
Smasher Shor t s
Lucky Tech I nt er gal Wp/ B Rai n Pant s
Basi c 10, Lef t , Yel l ow/ Bl ack
Expedi t i on Zer o, Medi um, Ri ght , Char coal
Expedi t i on 20, Medi um, Ri ght , For es t gr een
Fami l y Hol i day 4
Hur r i cane 4
SA
op
yr
ig
ht
ed
-D
no
t
1
2
3
4
5
6
7
8
9
10
Pr oduct
Number
Or der s
re
di
st
Obs
ut
e
12-8
ut
e
Exercises
rib
Level 1
re
di
st
no
t
c. Display separate statistics for the combination of Order_Date and Order_Type. Apply the
ORDERTYPES. format so that the order types are displayed as text descriptions, not numbers.
Apply the YEAR4. format so that order dates are displayed as years, not individual dates.
d. Submit the program to produce the following report:
Partial PROC MEANS Output
-D
Anal ysi s Var i abl e : Tot al _Ret ai l _Pr i ce Tot al Ret ai l Pr i ce f or Thi s Pr oduct
2004
SA
op
yr
ig
ht
ed
Dat e
Or der
was
pl aced
by
Or der
N
Cust omer
Type
Obs
Sum
2003
Ret ai l
53
7938. 80
2005
Cat al og
52
10668. 08
I nt er net
23
4124. 05
Ret ai l
63
9012. 22
Cat al og
23
3494. 60
I nt er net
22
3275. 70
Ret ai l
34
5651. 29
Cat al og
33
6569. 98
I nt er net
23
4626. 40
12-9
Level 2
rib
b. Display the number of missing values and the number of nonmissing values present in the
Birth_Date, Emp_Hire_Date, and Emp_Term_Date variables.
re
di
st
ut
e
e. Suppress the output column that displays the total number of observations in each classification
group.
f. Submit the program to produce the following report:
PROC MEANS Output
no
t
-D
Empl oyee
N
Gender
Var i abl e
Label
Mi ss
N
F
Bi r t h_Dat e
Empl oyee Bi r t h Dat e
0
191
Emp_Hi r e_Dat e
Empl oyee Hi r e Dat e
0
191
Emp_Ter m_Dat e
Empl oyee Ter mi nat i on Dat e
139
52
Bi r t h_Dat e
Empl oyee Bi r t h Dat e
0
233
Emp_Hi r e_Dat e
Empl oyee Hi r e Dat e
0
233
Emp_Ter m_Dat e
Empl oyee Ter mi nat i on Dat e
169
64
ht
ed
yr
ig
Level 3
op
SA
2) Mean
3) Upper Confidence Limit for the Mean
c. Change the value for the confidence limits to 0.10, resulting in a 90% confidence limit.
12-10
d. Display all countries stored in the Work.countries data set in the report, even
if there are no customers from that country.
rib
ut
e
Documentation about the MEANS procedure can be found in the SAS Help and
Documentation from the Contents tab (SAS Products Base SAS
Base SAS 9.2 Procedures Guide Procedures The MEANS Procedure).
Look for options in the PROC MEANS statement that can perform the requested actions.
re
di
st
Anal ysi s Var i abl e : Cust omer _Age Cus t omer Age
CA
15
31. 2270622
40. 0000000
48. 7729378
DE
10
35. 2564025
46. 6000000
57. 9435975
DK
ES
IL
30. 1150331
40. 0000000
49. 8849669
NL
NO
PT
SE
TR
30. 5050705
39. 4285714
48. 3520724
US
28
35. 6505942
40. 4285714
45. 2065486
SA
op
yr
ig
ht
GB
ed
FR
-D
BE
no
t
Cust omer
N
Lower 90%
Upper 90%
Count r y
Obs
CL f or Mean
Mean
CL f or Mean
AU
8
42. 4983854
52. 3750000
62. 2516146
ZA
4
12. 1696649
34. 7500000
57. 3303351
12-11
b. Create an output data set containing the sum of Total_Retail_Price values for each
Product_ID.
ut
e
rib
Creating an output data set from PROC MEANS results is discussed in the self-study
content at the end of this section.
re
di
st
c. Combine the output data set with orion.product_list to obtain the Product_Name
value for each Product_ID code.
d. Sort the merged data so that the products with higher revenues appear at the top of the resulting
data set. Print the first 10 observations, that is, those that represent the ten products with the most
revenue.
no
t
e. Display the revenue values with a leading euro symbol (), a period that separates every three
digits, and a comma that separates the decimal fraction.
-D
391,
080,
250,
937,
796,
561,
514,
510,
424,
343,
C
S
SA
80
30
00
20
00
80
40
80
40
30
230100700009
230100700008
230100700011
240200100173
240200100076
240300300090
240300300070
240100400098
240100400129
240100400043
ht
3.
3.
2.
1.
1.
1.
1.
1.
1.
1.
op
1
2
3
4
5
6
7
8
9
10
Pr oduct
Number
Revenue
yr
ig
Obs
ed
Pr oduct
Fami l y Hol i day 6
Fami l y Hol i day 4
Hur r i cane 4
Pr opl ay Execut i v e Bi - Met al Gr aphi t e
Exper t Men' s Fi r esol e Dr i ver
Top R&D Long Jac ket
Top Men' s R&D Ul t i mat e Jacket
Rol l er skat e Rol l er Skat es Ex9 76mm/ 78a Bi of l
Rol l er skat e Rol l er Skat es Sq9 80- 76mm/ 78a
Per f ect Fi t Men' s Rol l er Skat es
12-12
ut
e
Exercises
rib
Level 1
9. Creating a Simple Tabular Report with PROC TABULATE
re
di
st
no
t
2) An extra row that combines all groups appears at the bottom of the table.
-D
4) The N and MEAN statistics based on Customer_Age are displayed for each
combination of Customer_Group and Customer_Gender.
e. Submit the program to produce the following report:
ed
ht
SA
op
yr
ig
Mean
Mean
Cust omer Gr oup Name
I nt er net / Cat al og
Cust omer s
4. 00
49. 25
4. 00
54. 25
Or i on Cl ub Gol d
member s
11. 00
35. 36
10. 00
38. 90
Or i on Cl ub member s
15. 00
32. 53
33. 00
47. 03
Al l
30. 00
35. 80
47. 00
45. 91
12-13
Level 2
ut
e
rib
re
di
st
3) The column dimension should display the number of customers and the percentage
of customers in each category (COLPCTN).
Change the headers for the statistic columns with a KEYLABEL statement.
Documentation about the KEYLABEL statement can be found in the SAS Help
and Documentation from the Contents tab (SAS Products Base SAS
Base SAS 9.2 Procedures Guide Procedures The TABULATE Procedure).
no
t
SA
op
yr
ig
ht
ed
-D
Number
Per cent age
Cust omer Gr oup Name
I nt er net / Cat al og
Cust omer s
4. 00
13. 33
Or i on Cl ub Gol d
member s
11. 00
36. 67
Or i on Cl ub member s
15. 00
50. 00
12-14
rib
re
di
st
Number
Per cent age
Cust omer Gr oup Name
I nt er net / Cat al og
Cust omer s
4. 00
8. 51
Or i on Cl ub Gol d
member s
10. 00
21. 28
Or i on Cl ub member s
33. 00
70. 21
ut
e
Level 3
no
t
-D
ed
e. Insert this text into the box above the row titles: High Cost Products (Unit Cost >
$250). Suppress all titles.
f. Display all calculated cell values with the DOLLAR12. format.
yr
ig
Documentation about the TABULATE procedure can be found in the SAS Help
and Documentation from the Contents tab (SAS Products Base SAS
Base SAS 9.2 Procedures Guide Procedures The TABULATE Procedure).
Look for features of the PROC TABULATE statement, the TABLE statement, and
the KEYLABEL statement that can perform the requested actions.
SA
op
ht
12-15
no
t
re
di
st
rib
ut
e
Hi gh Cost Pr oduct s
$0
$0
$0
$1, 200
2005
$2, 057
$2, 256
$0
$0
2006
$0
$1, 136
$0
$0
2007
$519
$0
$1, 066
$0
b. Create an output data set from the PROC TABULATE results. The output data set should contain
average salaries for each combination of Company and Employee_Gender, plus overall
averages for each Company.
-D
Creating an output data set from PROC TABULATE results is discussed in the self-study
content at the end of this section.
SA
op
yr
ig
ht
ed
d. Print the sorted data set. Assign a format and column header to the average salary column.
12-16
ht
yr
ig
op
C
S
SA
M
M
F
M
M
F
F
M
F
M
760
167
574
226
534
963
375
462
839
650
408
055
556
645
128
428
390
631
016
132
630
370
034
831
rib
$27,
$29,
$30,
$31,
$32,
$32,
$33,
$33,
$33,
$34,
$38,
$39,
$41,
$42,
$43,
$43,
$44,
$44,
$46,
$47,
$47,
$68,
$134,
$212,
no
t
F
F
M
Aver age
Sal ar y
re
di
st
F
F
Or i on Aust r al i a
Or i on USA
Or i on Aust r al i a
Or i on USA
Or i on USA
Or i on Aust r al i a
Concessi on
Pur chasi ng
Concessi on
Concessi on
Pur chasi ng
Logi st i c s
Pur chasi ng
Mar ket i ng
Logi st i c s
Shar ed Funct i ons
Mar ket i ng
Shar ed Funct i ons
Shar ed Funct i ons
Mar ket i ng
Logi st i c s
Boar d of Di r ect or s
Boar d of Di r ect or s
Boar d of Di r ect or s
ed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Empl oyee
Gender
Company
-D
Obs
ut
e
12-17
Chapter Review
no
t
re
di
st
rib
SA
op
yr
ig
ht
ed
-D
114
ut
e