Exercises for Learning SAS Programming

sasbookOur 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

Short Answer

  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.

Post a Comment

Tips on mixing Grandpa McCafferty’s cough syrup: A statistically designed experiment

HeathRushing

Heath Rushing

This tip is from Heath Rushing, coauthor of Design and Analysis of Experiments by Douglas Montgomery: A Supplement for Using JMP®.

After a recent design of experiments (DOE) course, a student asked about experiments with dependent factors. Throughout the two days of training, we spent considerable time designing experiments to determine the effect of one or more independent factors on multiple responses. However, in her particular experiment, she was mixing three different components in a formulation. The level of each of the three components were proportions of a mixture. This is known as a mixture design.

Her ultimate goal was to determine the proportion for each of the components to optimize multiple responses. Because she could not discuss the details of the responses or components, I referred to her formulation as Grandpa McCafferty’s cough syrup. The understanding of three key concepts was needed for her experiment:

Recognize a mixture design. In most designed experiments, the factor settings are assumed to be independent of the other factor settings; one factor can be varied independently of the level of the other factors. If the factors in the experiment are components in a mixture where the factor levels are proportions (of that particular component), the mixture factor cannot be varied independently of the other factors. Because the levels of mixture factors sum to 100%, by increasing or decreasing the proportion of one, the level of at least one of the others must decrease or increase. Read More »

Post a Comment

25 years – 25% discount at JSM, Seattle!

120084856This year, to celebrate the 25th anniversary of SAS Press, we are offering a 25% discount on all our SAS Press books at JSM (Joint Statistical Meetings). Over the last 25 years, SAS Press has published 250 books; has worked with more than 300 SAS authors and has millions of satisfied SAS users! So come and celebrate with us and get your 25% discount on one or more of our great titles.

I’m sure by now you will have heard about SAS® University Edition, which provides free access to SAS software quickly and easily for students, professors and independent learners. Bestselling author, Ron Cody has just finished his latest title, An Introduction to SAS University Edition - which does what it says on the jar -  and provides a comprehensive guide on how to get started with SAS University Edition and use it to solve problems, using the point-and-click interface of SAS Studio, and how to write your own SAS programs. Come and visit the SAS Press booth and take a look at the preview copy.

So you have the software, and know there is a great book coming soon to get you up and running, but where to get the data? Free Data Friday is a new initiative from the SAS Analytics U community starting this fall. Over a series of 12 blogs, the community will show where to get a particular data set, how to read it into SAS, at least one model or statistic showing something interesting with that data, and at least one ODS or SAS Studio graph to show the results. Read More »

Post a Comment

Macros Tip: %INCLUDE vs. Macro Language

Robert Virgile

Robert Virgile

This SAS author tip is from Robert Virgile, author of “SAS Macro Language Magic: Discovering Advanced Techniques”.  It actually came about when a reader posted a comment on one of Virgile’s blogs. Thank you to that reader for their comment!

Technically, %INCLUDE is not part of macro language.  Yes, it begins with a percent sign, but it is still a different tool.  What they share: for some applications, %INCLUDE is an alternative to macro language.

First, let’s review a few basics.  %INCLUDE always references a file.  Two typical examples:

%include 'complete path to a file';
 
filename somename 'complete path to a file';
%include somename;

Read More »

Post a Comment

Narrow miss at PharmaSUG 2015 for bestseller

Bill Benjamin’s bestseller, Exchanging Data between SAS and Microsoft Excel: Tips and Techniques to Transfer and Manage Data More Efficiently, was pipped at the post as he narrowly missed the top spot to Implementing CDISC Using SAS: An End-to-End Guide, at last month’s PharmaSUG 2015 meeting in Orlando -- by one sale!

Here's the list of the top 5 bestselling SAS books at PharmaSUG: 

  1. Implementing CDISC Using SAS: An End-to-End Guide, Chris Holland & Jack Shostak
  2. Exchanging Data between SAS and Microsoft Excel: Tips and Techniques to Transfer and Manage Data More Efficiently, William Benjamin
  3. Getting Started with the Graph Template Language in SAS: Examples, Tips, and Techniques for Creating Custom Graphs, Sanjay Matange
  4. SAS Programming in the Pharmaceutical Industry, Second Edition, Jack Shostak
  5. ODS Techniques: Tips for Enhancing Your SAS Output, Kevin D. Smith

Congratulations to Jack Shostak for appearing twice in the top five, and topping the sales together with Chris Holland! Mirroring the theme of the conference, the pharma titles did well and we should be seeing some pretty graphs and output if the other bestsellers are anything to go by.

A big thank you to all who came to visit the SAS press booth. We’re glad our exclusive SAS buttons and stickers were such a hit – please wear them with pride all you Data Divas and Data Dudes! We’ll be bringing them again to the Joint Statistics Meeting coming up in Seattle - so if you missed out in Orlando - make sure you get there early!

SAS_books_buttons

Inspired to write your own book for SAS? Then please contact us at saspress@sas.com.

Post a Comment

Top 10 bestselling titles at SAS Global Forum 2015

SASGlobalForum_sasbooks

SAS Global Forum bestselling author - William E. Benjamin, Jr.

The final figures are in! This year there was a fierce battle for the top spot of the SAS Global Forum 2015 books bestseller list.

In a nail biting finish, newcomer, Exchanging Data between SAS and Microsoft Excel: Tips and Techniques to Transfer and Manage Data More Efficiently, beat off the all-time classic, The Little SAS Book: A Primer, Fifth Edition, and Art Carpenter’s latest,  Carpenter's Guide to Innovative SAS Techniques. On site sales showed a level setting but the off-site orders, using the special conference discount code, came pouring in and tipped the balance heavily in favor of Bill Benjamin’s Exchanging Data title.

Read More »

Post a Comment

3 reasons you need the new edition of PROC TABULATE by Example

PROC_TabulateWhat prompted me to find a co-author and write a new edition of my original book on PROC TABULATE? It’s those inventive developers at SAS. They keep adding new features to make the product even better.  There are too many new features and techniques in the book to name, but these are my top three reasons why you need to check out the new content:

  1. Percentages are now much easier

When I wrote the original book, to use percentages you had to figure out the denominator definitions by yourself. That created an entire chapter of complex explanations.  Now you can use ROWPCTN, ROWPCTSUM, COLPCTN, and COLPCTSUM to do row and column percentages with ease. The new edition shows how you can use these new statistic keywords to create clear and informative tables.

  1. The Output Delivery System (ODS) has matured as a product

There are so many new ways you can use ODS today. In the original book, written based on SAS v7, ODS was in its infancy and users were just beginning to understand its power. Today, with continued development at SAS, and many creative ideas contributed by users online and at conferences, this section is greatly expanded with new ways to make your output more professional and powerful.

  1. New tricks and cheats

No matter how good the developers at SAS, the SAS user community is always one step ahead. The new version of the chapter "PROC TABULATE Tricks: How to Cheat to Create Complex Tables” is full of ways to create customized output using clever workarounds.

Visit the book page for additional information, reviews and a free book excerpt.

Post a Comment

Macro Myth: The closest non-empty symbol table

Robert Virgile

Robert Virgile

This SAS tip is from Robert Virgile and his book “SAS Macro Language Magic: Discovering Advanced Techniques”.

We hope you find this tip useful. You can also read an excerpt from Virgile’s book.

When CALL SYMPUT creates a new macro variable, it places that variable in “the closest non-empty symbol table.”  But what does that mean?  And why does CALL SYMPUT exhibit such unusual behavior?

Read More »

Post a Comment

Get real clinical data

clinicalMany of our authors often ask us where they can find real data that they can use without copyright or other confidentiality issues. Instructors too are always on the look-out for real-life data.

Well, thanks to a new initiative supported by SAS, you can now access data from more than 40 studies and 25,000 patients from clinical trials of prostate cancer, breast cancer, and melanoma treatments. The list of available studies is growing rapidly! See for yourself.

Project Data Sphere, founded by the CEO Roundtable on Cancer, brings together leading pharmaceutical companies to share data and an analytics platform to investigate those data. In support of Project Data Sphere and the research community, SAS hosts the platform and provides access to SAS Drug Development and SAS Visual Analytics at no cost to researchers.  For most studies, data is already available as SAS data sets, consistent with CDISC/SDTM requirements and ready for analysis using the web-enabled analytics platform.  Students, professors, and others in the research community are welcome to join this growing community of clinical trial researchers in the fight against cancer.

So what better time to write a book with all this data to play with! I’m headed to Orlando, May 17- 20, for the annual PharmaSUG conference. I will be at the SAS Publications booth in the demo room and would love to talk to you about your book ideas, whether you want to write your own book, review a book, or suggest a book idea. We are actively looking to expand our offerings to cover a variety of pharmaceutical topics; and so if you have an interesting application or experience in using SAS solutions, then please consider sharing it as a short book.

Please do stop by the demo room at PharmaSUG 2015 or email me if you'd like to set aside some time to talk.

Post a Comment

Top 3 benefits of writing a SAS book

Many colleagues and customers at SAS Global Forum ask me, why I write books beside having a full-time job as SAS consultant and being lecturer at universities. Valid question.

  1. SUSTAINABILITY. I have been working in so many analysis projects in different domains and industries. Some of them were longer, others were shorter engagements, and I found out that I wanted to create and produce something that lasts for a long period of time and that is connected with my name. A book is definitely a good idea for this.
  2. YOU EDUCATE YOURSELF! Yes, the content of both of my books was known to me before I started writing. They are a collection of experiences from interacting with SAS Users in the field of analytics over many years. But a book forces you to structure the content, divide your ideas into chapters, formulate your experiences and ideas in an explicit way. After completing each book I felt more knowledgeable. And even more important: I was able to formulate my ideas, my knowledge and solutions more explicitly. And I often benefit of this experiences in customer meetings, presentations and discussions.
  3. YOU GET FEEDBACK. There are many rewarding moments when being a SAS Author: You are part of the community of SAS authors, you work together with the team of SAS Press and most important you get feedback from your readers. I receive emails from all over the world from readers who let me know how they used the ideas presented in my books. You are always happy to hear that readers like and use your work. You are also happy to hear if they suggest improvements as this shows that they really got involved with your work.

And the most rewarding moment for an author is to see customers holding his books in their hands.

SASBOOKs

 

Post a Comment