Recent studies show that the annual winter migration of millions of monarch butterflies from the US to Mexico is at risk of disappearing - can SAS graphics help change that?!?
When I was a kid (not that long ago), one of my main activities was the 4-H Entomology project. I collected insects, and one of my collections even won a blue ribbon in the NC State Fair. I remember how fascinated I was when I heard that the monarch butterflies migrated all the way to Mexico, and hung out on a certain mountain there all winter.
Last week, I read an article that made me very sad - they say that in recent years the number of monarchs migrating to Mexico has gone down drastically. The butterflies covered 44.5 acres in 1996, 2.9 acres last year, and only 1.7 acres this winter.
So I decided to do what I could to help save the monarchs. I ordered several kinds of milkweed seed which I'm going to plant in my back yard this spring (milkweed plants are very important to monarchs). I encouraged the landscapers at the SAS headquarters in Cary, and the Town of Cary landscapers to include milkweed in their landscaping (and they seemed very receptive to this idea).
And I thought I might use my blog, and my SAS graphics skills to help raise awareness of this problem, and encourage others to also plant milkweed and provide more habitat for monarchs. What better way to do that, than with a really cool SAS graph animation of some monarch butterfly data!
I found a website where people have been tracking their 'first sighting' of monarchs in the spring. Their database has both the date, and the location. They show this migration data plotted on a static map (with the markers color-coded in a gradient representing the date the butterflies were first seen).
But I thought it might also be interesting to see the data in an animation... Click the map snapshot below, to see my SAS gif animation. One cool thing about it is that the way the dots 'dance' around the page during the animation almost looks like butterflies flitting around! :)
If you've had a cool experience with monarchs, or if you'll commit to planting some milkweed to help provide them with more habitat, leave a comment to let everyone know! :)
butterfly photo credit: Suzanne Marie (flickr)
replace the dbms=EXCEL with the appropriate suffix of your file type, i.e., dbms = xlsx or dbms = xls or dbms = cvs etc.
Pingback: Are milkweed and monarchs making a comeback? - SAS Learning Post
I am newbie in SAS and taking training in base/advanced SAS. I saw the link to the code and was trying to see how it works ! So I imported the excel and imported using PROC Import, While doing this alone, Am getting LOg Error saying Class Not Registered and Error in Libname. Can you guide me on what I must have done wrong? Here is the code
PROC IMPORT DATAFILE="C:\Anu\SAS\SAS-Monarch Butterfly Project\monarch_first_sightings_2013.xlsx" OUT=mydata
DBMS=EXCEL REPLACE ;
I believe this is the message you get when you use 64-bit SAS with 32-bit Microsoft Office (of which Excel is a part of). I had this same problem when I first upgraded to 64-bit SAS, and I worked-around it by installing the 64-bit Microsoft Office.
There are a few other work-arounds, and you might want to talk to SAS Tech Support to see which one suits your situation best. Also, here is a blog by Chris Hemedinger that covers this topic (see "Gotcha #1"):
Very nice. I will plant milkweed this spring!
As for the visualization, wondering if you also tried it with a "cumulative" animation. That is, instead of plotting where they are first seen, just add new dots where they are first seen but don't turn off the old dots. So you would see like a wave of monarchs as they spread over the US.
Since you were kind enough to post the code, maybe I'll give it a try (would be my first animated graph!)
Glad to hear that you'll plant some milkweed! And interesting idea about the alternate way to do the animation.
If you'd like to play with it, here's a link to the code:
And/or the web folder is open for you to look around:
Great idea. I remember years ago when a Monarch hatched out in my kitchen. Will never forget it sitting on my hand and crawling up my arm. Greatest joy of all was when my son and I released it and watched it fly away. Beautiful. Plant milkweed! Monarchs are awesome.
What a great memory!