Sep
20
How Did I Get from SAS to a Talking Monkey?
September 20, 2017 | Leave a Comment
Today, I finished up a bonus Easter egg for the game, Aztech: Meet the Maya that you are taken to play when you click to see what Jose is thinking. You can see a rough version of it here. This plays better on a desktop / laptop because iPad blocks the autoplay for sound, but when it’s packaged for the app store, that will work on the iPad as well.
This game uses several functions, all of which I wrote my little old self.
- Switches sound file played from English to Spanish
- Switches text from English to Spanish
- Takes you to the bonus game when you click on the sound bubble
- When the sound file ends, replaces the talking gif with a static image and shows the arrow to continue.
- For each item on the screen, performs an action when clicked – anything from text describing it’s use to the Maya to a jumping and howling monkey. Also, removes that item name from the list of things to find, increases the number of found items by 1 and checks to see if all items are found.
There are probably some other things I forgot.
You might wonder how I got from SAS to here. Well, it all started with SAS macros. A macro is no more than a user-written function. When I was first exposed to this idea in graduate school back in the 1980s (yes, literally) my mind was blown! You mean, I could write my own functions?!
You might think this SAS macro that I wrote a couple of years ago
%macro sched(the_day,start1,finish1,teacher1,start2=0, finish2=0, teacher2=” “, start3=0,finish3=0, teacher3=” “);
if date_data = &the_day then do ;
if minutes > &start1 & minutes < &finish1 then tclass = &teacher1 ;
else if (&start2 > 0) & (minutes > &start2) & minutes < &finish2 then tclass = &teacher2 ;
else if &start3 > 0 & (minutes > &start3) & minutes < &finish3 then tclass = &teacher3 ;
end ;
%mend sched ;
doesn’t look like this JavaScript function
// Section to include sound. ;
function playJungleAudio(scene,langs) {
audio_e2 = new Audio();
audio_s2 = new Audio();
if(langs ===2){
audio_e2.src = "sounds/" + scene + "_eng.mp3";
audio_s2.src = "sounds/" + scene + "_sp.mp3";
if ($("#span_button").hasClass("noshow")) {
audio_e2.play();
} else {
audio_s2.play();
}
}
else {
audio_e2.src = "sounds/" + scene + ".mp3";
audio_e2.play();
}
}
If you look closely, though, these are identical in purpose and structure. Both are intended to package a set of statements that will then be executed when called. For both types of functions, SAS (macros) or JavaScript, parameters are optional. Both of these examples just happen to have parameters. Both have a defined start and stop.
In SAS it is
%macro macr0-name (parameters) ;
in JavaScript it is
function function-name(parameters) {
Both have a defined end, with SAS it is
%mend macroname ;
with JavaScript it is simply
}
Both are named functions (JavaScript also has anonymous functions), and when you call the function it executes.
It just so happens that both of these functions contain if-then – else statements.
To call the SAS macro, you give the macro name with a % in front of it, and include all the parameters in parentheses, separated by commas.
%sched(19292,790,840,”Elmo”,start2= 840, finish2=900, teacher2= “Bert”, start3=940,finish3=990, teacher3= “Snuffleupagus”);
To call the JavaScript function, you give the name, and include all parameters in parentheses, separated by commas.
playJungleAudio("howler_monkey",1);
These parameters are then passed to the macro/ function and their values are plugged into the code between the beginning and end.
I have a lot more to say about this but it is getting close to 1 am and I have a plane to catch tomorrow so I’ll have to pick it up next time.
Sep
18
The 5 Building Blocks of Success
September 18, 2017 | Leave a Comment
So you want to be a successful software developer / consultant ?
If you are in any kind of quantitative field you have a VAST range of options, from working at some of the largest companies in the world in marketing research to performing efficacy studies for non-profits whose staff members can be counted on one hand.
All of these broad number of opportunities require, at most, five building blocks:
- Programming concepts – You need to understand scope, do-loop, arrays, functions
- Data management – The thousand ways that users can enter data, and how to keep it from screwing up your results
- Working in a software development team – this is the part “self-taught” programmers are often not taught – documentation, testing and debugging
- Statistics – coming from the age when we inverted matrices by hand with a piece of pare and a pencil (not kidding) SAS, SPSS, R, Stastica, JMP and even Excel have made this a hundred times easier from when I started in the field
- Domain specific knowledge – by that, I mean if you are working in aerospace know something about what a transmitter and receiver are, know that a male and a female plug is a thing. If you are in biostatistics, understand survival analysis, relative risk.
(Yes, I know I said four in the previous post but then I thought about the importance of being able to work as part of a software development team and it’s my blog, so hush up.)
Since I started (mostly) with SAS, I’m going to talk for the next few posts about how starting as a SAS programmer can be like a Dr. Seuss book – “Oh, the places you’ll go!” My main point, as I have said before (weren’t you listening?) is that it doesn’t matter what language you use in the beginning. Eventually, I will tell you why SAS is a great place to start – better than many others – but it is not eventually yet. Patience is a virtue.
Let’s start with programming concepts. Now, I’d had a bit of BASIC, Fortran and COBOL before I got to SAS (yes, shut up, I’m old and in fact, yes I DID use a keypunch machine with punched cards like those women in Hidden Figures. When the movie came out, one of our interns, in all seriousness, asked me if I was in it. I’m not quite that old.)
The basic concepts I use almost every day:
Arrays – I’ve written about those on this blog a dozen time. One of the most frequent uses I make of SAS is to score tests, which requires creating an array of answers from a respondent and a second array of items scored correct or incorrect. Our game, Making Camp, that teaches multiplication and division, has a virtual trading post and a wigwam, both of which make extensive use of arrays. All of the items you can “buy” with the points you earned from solving math and history problems are in an array.
SOME SAS ARRAYS
Data scored ;
set mydata.data2013 ;
array ans{70} q1- q70 ;
array correct{70} c1 – c70 ;
array scored{70} sc1 – sc70 ;
SOME JAVASCRIPT ARRAYS
var things = [
“art/tomahawk.png”, “art/dog.jpg”, “art/pottery.png”, “art/deer_skin_sm.png”,
“art/bass_side.png”, “art/arrows_and_quiver.png”, “art/turtle.jpg”, “”,
“art/parfleche.png”, “art/feather_sm_side.png”,
“art/plate.png”
];
var things_name = [
“TOMAHAWK”, “DOG”, “POTTERY”, “DEER SKIN”, “BASS”, “ARROWS AND QUIVER”, “TURTLE”, “”, “PARFLECHE”, “FEATHER”, “PLATE”
];
Yes, they look a little different but the basic concept is the same.
In the SAS example, I’m matching three arrays – the answer the students gave, the correct answer and the item scored correct or incorrect.
In the JavaScript example, I am matching up two arrays, with the source for the image file and the alternate text for that element.
In her paper presented in 2010 at SAS Global Forum, Jennifer Waller says,
A SAS ARRAY is a set of variables of the same type that you want to perform the same operation on. The set ofvariables is then referenced in the DATA step by the array name. The variables in the array are called the “elements”of the array.
Sep
13
It only seems like this has nothing to do with statistics
September 13, 2017 | 2 Comments
Last post, I talked about bricolage, the fine art of throwing random stuff together to make something useful. This is something of a philosophy of life for me.
Seems rambling but it’s not …
Over 30 years ago, I was the first American to win the world judo championships. A few years ago, I co-authored a book on judo, called Winning on the Ground.
When it came to judo, although I was better than the average person, I was not the best at the fancy throws – not by a long shot. I didn’t invent any new judo techniques. I wanted to call our book The Lego Theory of Judo but my co-author said, “That’s stupid” and the editor, more tactfully, said, “Nobody will know what you are talking about unless they read the book and you want a title that will get them to buy the book”. So, I lost that argument.
What I was really good at was putting techniques together. I could go from a throw to a pin to an armbar and voila – world champion! Well, it took a long time and a lot of work, too.
How does this apply to statistics?
Let’s start with Fisher’s exact test. Last year, I wrote about using this test to compare the bureaucratic barriers to new educational technology in rural versus urban school districts. Just in case you have not memorized my blog posts, Fisher’s exact test can be used when you have a 2 x 2 matrix that fails to meet the chi-square minimum of five observations per cell. In that instance, with only 17 districts, chi-square would not be appropriate. If you have a 2 x 2 table, SAS automatically computes the Fisher exact test, as well as several others. Here is the code:
PROC FREQ DATA = install ;
TABLES rural*install / CHISQ ;
Ten years ago, I was using this exact test in a very different context, as a statistical consultant working with a group of physicians who wanted to compare the mortality rates between a department that had staff with a specific training program and a similar department where physicians were equally qualified except for participation in the specialized program. Fortunately for the patients but unfortunately for statistical analysis purposes, people didn’t die that often in either department. Exact same problem. Exact same code except for changing the variable names and data set name.
In 35 years, I have gone from using SAS to predict which missiles will fail at launch to which families will place their child with a disability in a residential facility to which patient in a hospital will die to which person in vocational program will get employed to which student will quit playing an educational game. ALL of these applications have used statistics and in some cases, like the examples above, the identical statistics applied in very diverse fields.
Where do the Legos come in?
In pretty much every field, you need four building blocks; statistics, foundational programming concepts, an understanding of data management and subject specific knowledge. SAS can help you with three of these and if you acquire the fourth, you can build just about anything.
More on those building blocks next post.
For random advice from me and my lovely children, subscribe to our youtube channel 7GenGames TV
Sep
13
Bricolage: My autobiography, with SAS procedures
September 13, 2017 | 2 Comments
I thought the title of Al Franken’s book , The Truth, with jokes , was great and I wanted to do something just like it. Unfortunately, I’m not that funny.
Often, the discussion comes up among colleagues whether it is better for one’s career to be a specialist or a generalist. It’s a little (a lot) too late for me to become the world’s foremost authority on PROC REPORT (that’s Kim Le Bouton, isn’t it?). Right after wondering whether anyone uses PROC REPORT any more, I starting thinking of all of the basic concepts I learned from it that I apply regularly, mostly with PHP.
My point, which you have by now despaired of me having, is that when it comes to starting a fascinating career, SAS is as good as starting place as any, and probably better than most.
If you decide to be a specialist, your career path probably looks something like this:
You get a bachelors and a masters in statistics, you become a data analyst and work your way up to managing the entire division. If you do that, work your way up the ranks to knowing absolutely everything about clinical trials of migraine drugs, you’ll probably end up with a nice house in the suburbs, a 401K and three weeks of vacation each year.
If that’s you, cool. To be honest, though, I look at friends who have spent 20, 30 or 40 years in the same company and think I would lose my mind.
But, you say,
What can I do? I have an M.S. in statistics (or business or sociology) and two years of experience using SAS. What options do I have?
Well, honey, you have come to the right blog. In my decidedly non-linear career, I have been an industrial engineer, professor in schools of education, engineering, business, liberal arts and human services. I think the only one I have missed is fine art. I’ve been a consultant, programmer, statistician, consultant again and now am president/co-founder of a gaming start-up.
Over the next few posts, I’ll explain a dozen ways in which I have built a career by bricolage – that is, from building stuff – programs, companies – using whatever was lying about . All of my various careers have had their roots in statistics and SAS. Could I have learned the same concepts and gotten the same results using another programming language, taking a different path? Probably. But I didn’t.
Blogroll
- Andrew Gelman's statistics blog - is far more interesting than the name
- Biological research made interesting
- Interesting economics blog
- Love Stats Blog - How can you not love a market research blog with a name like that?
- Me, twitter - Thoughts on stats
- SAS Blog for the rest of us - Not as funny as some, but twice as smart. If this is for the rest of us, who are those other people?
- Simply Statistics, simply interesting
- Tech News that Doesn’t Suck
- The Endeavor -John D Cook - Another statistics blog