Our new book, Exercises and Projects for The Little SAS® Book Fifth Edition, includes a variety of exercises to help people learn SAS programming. Rebecca Ottesen, Lora Delwiche and I designed this book so that it can be used either in a classroom setting or by individual readers working alone.

One of the challenges we faced in writing exercises was how to create questions that were thought-provoking and yet not too complicated for people who are just starting to learn SAS. Our goal was not only to test readers' knowledge, but to solidify that knowledge so they will remember what they learn. That's why we included different types of exercises. Multiple-choice exercises are quick and easy, open-ended short answer exercises encourage readers to think a little more deeply about the material, and then programming exercises challenge readers to apply what they have learned.

The following questions are examples of the three types of exercises found in our book. For help with these exercises, see section 4.13 "Producing Tabular Reports with PROC TABULATE" in The Little SAS® Book, Fifth Edition.

### Multiple Choice

1. For variables listed in a CLASS statement, what statistic will PROC TABULATE produce by default?

a. Sums
b. Percentages
c. Means
d. Counts

2. If you specify two dimensions in a TABLE statement in PROC TABULATE, which dimensions will you get?

a. Pages and rows
b. Pages and columns
c. Rows and columns
d. Columns and rows

1. Explain what happens to observations with missing values for variables listed in a CLASS statement in PROC TABULATE. Describe an option you can use to change this default behavior.
2. Is it possible to write a TABLE statement in PROC TABULATE that specifies a row dimension but no column dimension? Explain your answer.

### Programming Exercises

1. A friend, who has recently begun bird watching, keeps a list of birds. For each species, she records its name and three one letter codes. The codes indicate whether or not she has seen that species (S for seen, or N for not seen), the type of bird (G for game birds, S for songbirds, R for raptors, or W for waterfowl), and whether or not that species is migratory (M for migratory, or N for nonmigratory). Use the data in her list to create summary reports.

a.  Write a DATA step to read the following raw data into a SAS data set.

```Bald Eagle S R M Barn Owl S R M Gambel's Quail S G N Canada Goose S G N Cardinal N S N Common Loon N W M Condor N R N Crow S S N Elf Owl N R N Golden Eagle N R M Goldfinch S S M Magpie S S N Mallard S W M Meadowlark N S N Mockingbird S S N Osprey N R M Robin S S M Scrub Jay S S N Rock Ptarmigan N G N Turkey N G N```

b. Using PROC TABLULATE, produce a report with counts that specifies rows for the type of bird and columns for whether the bird has been seen. Be sure to include an appropriate title.

c. Create user-defined formats to replace the one letter codes with formatted values for the type of bird and whether or not it has been seen. Rerun the report using the new formats.

d. Use a different procedure to produce the same counts. Then add a comment to your program describing the differences between the two reports.

We hope that you found this information helpful. Visit the book page for additional information, reviews, and a free book excerpt.

Share