Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Filling in the blanks with PROC FREQ Bill Klein Ryerson University.

Similar presentations


Presentation on theme: "1 Filling in the blanks with PROC FREQ Bill Klein Ryerson University."— Presentation transcript:

1 1 Filling in the blanks with PROC FREQ Bill Klein Ryerson University

2 2 Objective To display values that do not exist

3 3 Listing shows zero amounts for Children’s, 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

4 4 Make 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";

5 5 data instock; input video @@; cards; 1 3 5 5 3 1 1 1 3 9 ; Input the data. The trailing double-@ sign allows the input statement to read more than one observation on each data line. The data stream is terminated with a semi-colon.

6 6 Display the contents of the input file. proc print data = instock; var video; format video videof.; run;

7 7 Children’s, 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

8 8 PROC FREQ cannot display data that have not been input or that do not exist. proc freq data=instock; tables video; title1 Zero frequencies for Children's, Drama,; title2 Travel and Romance are not shown; format video videof.;

9 9 PROC 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

10 10 Create dummy categories. data categories; do video=1 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;

11 11 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 Display of the dummy categories

12 12 proc freq data=instock noprint; tables video / out=videofreq; run; proc print data = videofreq; run; Create a file to contain counts.

13 13 Obs video COUNT PERCENT 1 1 6 50.0000 2 3 3 25.0000 3 5 2 16.6667 4 9 1 8.3333 The VIDEOFREQ file contains counts and percentages of items in stock.

14 14 proc sort data=instock; by video; proc print data=instock; title The inventory file after sorting; Sort the inventory file by VIDEO.

15 15 The 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

16 16 Match the inventory file with the dummy variables in VIDEOFREQ data video; update videofreq categories; by video; proc print data=video; run;

17 17 Missing 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

18 18 Replace 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";

19 19 Print the final result proc print data=video 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;

20 20 Listing shows zero amounts for Children’s, 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


Download ppt "1 Filling in the blanks with PROC FREQ Bill Klein Ryerson University."

Similar presentations


Ads by Google