Title: Filling in the blanks with PROC FREQ
1Filling in the blanks with PROC FREQ
Bill
Klein
Ryerson
University
2- Objective
- To display values that do not exist
3Listing shows zero amounts for Childrens, Drama,
Travel and Romance
Stock on hand at Bill's Video Emporium
Number Category in stock
Percent Adventure 6
50 Children's 0 0 Comedy
3 25 Drama 0
0 Games 2
17 Travel 0 0 Romance
0 0 Miscellaneous 1
8
12 100
4Make format values for all categories, including
categories that are missing. proc format value
videof 1"Adventure" 2"Children's"
3"Comedy" 4"Drama"
5"Games" 6"Travel"
7"Romance
other "Miscellaneous"
5Input the data. The trailing double-_at_ sign allows
the input statement to read more than one
observation on each data line. The data stream is
terminated with a semi-colon.
data instock input video _at__at_ cards 1 3 5 5 3
1 1 1 1 1 3 9
6Display the contents of the input file.
- proc print data instock
- var video
- format video videof.
- run
7Childrens, Drama, Travel and Romance are not
listed. Obs video 1 Adventure 2
Comedy 3 Games 4 Games 5
Comedy 6 Adventure 7 Adventure
8 Adventure 9 Adventure 10
Adventure 11 Comedy 12 Miscellaneous
8PROC FREQ cannot display data that have not been
input or that do not exist.
- proc freq datainstock
- tables video
- title1 Zero frequencies for Children's, Drama,
- title2 Travel and Romance are not shown
- format video videof.
9PROC FREQ cannot display data that have not been
input.
- Zero frequencies for Children's, Drama,
- Travel and Romance are not shown
- The FREQ Procedure
- Cumulative
Cumulative - video Frequency Percent Frequency
Percent - --------------------------------------------------
--- - Adventure 6 50.00 6
50.00 - Comedy 3 25.00 9
75.00 - Games 2 16.67 11
91.67 - Miscellaneous 1 8.33 12
100.00
10Create dummy categories.
- data categories
- do video1 to 7
- output
- end
- proc print data categories
- title1 The seven dummy categories
- title2 Use the same variable name that was
used in the video inventory
11Display of the dummy categories
The seven dummy categories
Use the same
variable name that was used in the video
inventory Obs video 1 1 2
2 3 3 4 4 5
5 6 6 7 7
12Create a file to contain counts.
proc freq datainstock noprint tables
video / outvideofreq run proc print data
videofreq run
13The VIDEOFREQ file contains counts and
percentages of items in stock.
Obs video COUNT PERCENT 1 1
6 50.0000 2 3 3
25.0000 3 5 2 16.6667 4
9 1 8.3333
14Sort the inventory file by VIDEO.
proc sort datainstock by video proc print
datainstock title The inventory file after
sorting
15The sorted inventory file
- The inventory file after sorting
- Obs video
- 1 1
- 2 1
- 3 1
- 4 1
- 5 1
- 6 1
- 7 3
- 8 3
- 9 3
- 10 5
- 11 5
- 12 9
16Match the inventory file with the dummy variables
in VIDEOFREQ
- data video
- update videofreq categories
- by video
- proc print datavideo
- run
17Missing values occur for items that are not in
stock.
-
- Obs video COUNT PERCENT
- 1 1 6 50.0000
- 2 2 . .
- 3 3 3 25.0000
- 4 4 . .
- 5 5 2 16.6667
- 6 6 . .
- 7 7 . .
- 8 9 1 8.3333
18Replace missing values with zero and add labels
- data video
- update videofreq categories
- by video
- if count . then count 0
- if percent . then percent 0
- label video "Category"
- count "Number in stock"
- percent "Percent"
19Print the final result
- proc print datavideo noobs label
- var video count percent
- sum count percent
- format video videof. percent 5.0
- title1 "Stock on hand at Bill's Video
Emporium" - run
20Listing shows zero amounts for Childrens, Drama,
Travel and Romance.
- Stock on hand at Bill's Video Emporium
- Number
- Category in stock Percent
- Adventure 6 50
- Children's 0 0
- Comedy 3 25
- Drama 0 0
- Games 2 17
- Travel 0 0
- Romance 0 0
- Miscellaneous 1 8
-
- 12 100