BookmarkSubscribeRSS Feed

Take the Program Debugging Challenge

Started ‎04-09-2018 by
Modified ‎09-04-2018 by
Views 8,996

Let's check out those program debugging skills!

 

Debugging your own code can be difficult at times, but what if you're debugging code another programmer wrote? What about a program you've inherited? Maybe you need to help troubleshoot with a coworker? All of these scenarios can be so frustrating you want to pull your hair out (for me that's physically impossible). But never fear, practice is here!

 

The "Program Debugging Challenge" provides a real-word scenario for you to practice debugging code. In this challenge you will test your SAS programming and problem-solving skills by debugging someone else's program.

 

Scenario

You are an analyst at the National Hurricane Center. Your department has been working on a project to create a program that will enable the department to increase efficiency when analyzing and reporting storms.

 

Currently, this process is done manually, but a previous analyst attempted to streamline the process using SAS. The analyst was close to finishing but has been pulled off the project.


With your SAS experience, your manager has tasked you with debugging the program that the previous analyst wrote. However, this program contains logic and syntax errors. Lucky for you, the previous analyst has documented many of the issues.

 

Now you're thinking, am I ready to attempt the challenge? Well, before you do, know that this program is not for the faint-hearted.

 

I'm just being dramatic. It's really not that bad. For this challenge, having an understanding of base SAS, entry level macro, SQL and ODS will help you. But if you don't have a lot of experience with some of these, don't fret! There are hints for every issue and a suggested answer is included. So hey, give it a shot. Who knows, you may learn something new! 

  

To attempt this challenge, start by watching the introductory video. It will give you the background information on the data, desired outcomes, resources and a challenge overview.

 

 

 

When you're ready, download the materials:

 

  • Program Debugging Challenge PDF
  • Program Debugging Challenge PowerPoint
  • SAS Data sets (2): 
  • Storm Challenge Program 
Comments

These are really great exercises, thanks for publishing them! I think they'll come in handy as training materials for analysts or reminders for us 'experienced' analysts. 

It's great stuff and thanks for sharing it.

 

I have found what I think is a bug in the logic of the request (as well as data errors). 

 

For example, storm 1962BERNICE has 3 records for 06SEP1962, 1 as a tropical storm and 2 as a Extratropical Cyclone...all with the same (and incorrect) max wind speed of 45 (should be 50, according to

https://en.wikipedia.org/wiki/1962_Pacific_hurricane_season#Tropical_Storm_Bernice). 

 

Now, with the (fixed) logic of the program, it'll set MaxStatus as TS rather than EX  I guess I'll claim that a cyclone is more than a tropical storm as so the max should be EX instead.

 

Just a fun thought...not in any way meant to take away from the great piece of work that it is.

Excellent find! Thanks for pointing that out!

 

The differences between determining the storms is a bit more complicated than only wind speed, but for the sake of the challenge I kept all the assumptions simple 😊.  

 

I ran into the same discrepancies with the data and Wikipedia (same thing happens with category). One reason is the basic assumptions I made in the program. Another reason is most likely because Wikipedia has a 1-minute sustained peak intensity for wind speed, while the data has six-hourly information collected. I am not exactly sure how max wind speed is determined in that six-hour interval, but I think that's where that difference lies.

 

Another interesting storm to look at is StormKey "2014GENEVIEVE". Genevieve was the only storm missing a status description. According to Wikipedia, Genevieve was the first one to track across all three northern Pacific basins since Hurricane Dora in 1999.

 

https://en.wikipedia.org/wiki/Hurricane_Genevieve_(2014)#Intensification_and_peak_intensity

 

Looking at the details of Genevieve, you can see the status moves from HU to ST as the wind picks up. From my research (I am no expert on the subject) it seems that Genevieve may have been considered a super-typhoon (ST) since it crosses the Northwest Pacific at that time.

 

Difference between a hurricane and a typhoon

 

Only thing is that to be considered a super-typhoon you need 1-minute sustained surface winds of at least 150mph. Again, leaving us the question how is the max wind speed determined in that six-hour interval since it does not show 150+ in our data.

 

What is a super-typhoon?

 

Since the data we used is for Atlantic, Northeast and North Central Pacific, it causes the missing description for status!

 

 

I think understanding how the max wind speed is determined in that six hour interval would be great in answering our questions!

what I ended up doing in my project (which I call StormyDaniels.egp) is creating an alternative to the STORM_LOOKUP table:

 

data data.SaffirSimpson;
level=1; class='td'; desc='Tropical depression'; minspd=0; maxspd=38; output;
level=2; class='ts'; desc='Tropical storm'; minspd=39; maxspd=73; output;
level=3; class='c1'; desc='Category One'; minspd=74; maxspd=95; output;
level=4; class='c2'; desc='Category Two'; minspd=96; maxspd=110; output;
level=5; class='c3'; desc='Category Three'; minspd=111; maxspd=129; output;
level=6; class='c4'; desc='Category Four'; minspd=130; maxspd=156; output;
level=7; class='c5'; desc='Category Five'; minspd=157; maxspd=999; output;
run;

 

max(level) then gives me the description of any given storm.  So, for Genevieve , I get 'Category Four' as max status.

I like the solution tomrvincent. Love that you adjusted the lookup table to your needs!

Debug 1

 

Input function couldn't Convert a numeric value to a character value using a format*

 

I just replaced

Category=input( MaxWindSpeed, StormCategory. );

with following

Category=put( MaxWindSpeed, StormCategory. );

and it woked.

 

Debug 2

 

Following

 

	if StormKey then call symputx('EndingYear',year(date));/*Create the last year macro variable*/

  was replaced by

 

	if last.StormKey then call symputx('EndingYear',year(date));/*Create the last year macro variable*/
VDD

I thank you for this exercise.  Very well done.

 Glad you enjoyed it!

Version history
Last update:
‎09-04-2018 09:29 AM
Updated by:

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Article Labels
Article Tags