1 / 20

Filling in the blanks with PROC FREQ Bill Klein

Filling in the blanks with PROC FREQ Bill Klein Ryerson University. Objective To display values that do not exist. Listing shows zero amounts for Children’s, Drama, Travel and Romance.

newton
Download Presentation

Filling in the blanks with PROC FREQ Bill Klein

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Objective To display values that do not exist

  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. 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. 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. data instock; input video @@; cards; 1 3 5 5 3 1 1 1 1 1 3 9 ;

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

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

  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. 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. Display 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

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

  13. The 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

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

  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. Match the inventory file with the dummy variables in VIDEOFREQ data video; update videofreq categories; by video; proc print data=video; run;

  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. 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. 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. 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

More Related