I saw this poster in a high school, supposedly said by a basketball coach:

People say, “Follow your dreams. ” I say, “Forget your dreams, kid, follow math.”

He goes on to give the percentage of high school athletes who compete in college – 3.4% for men’s basketball, by the way, 1% of high school athletes make it in Division I. Even if you make it to the college level, your odds of becoming a professional athlete are dismal – 1.1% of college basketball players make it to the major professional teams, yes, that is 1% of 1%, so you have a .01% chance of making it into the Lakers even if you are playing in high school.

If you are that 1 in 10,000 who makes it on the roster, your median salary will be $3.7 million and you will play for around 4.8 years, giving you a career salary of around $18.5 million.

Let’s say you are a statistician with a Ph.D.  With 5-9 years of experience, your median salary is around $130,000. In my experience, it is going to be considerably less your first year but go up fairly rapidly. Let’s say you have the sense to get some scholarship and grant funds to pay for your tuition – my total student loan debt was $900 – and that you graduate in your 30s – I was 31 and that was with taking a few years out to work as an engineer. There isn’t any particular reason you have to retire before 65 or 70. It’s not like your knees go out and they fire you from your statistician job.  I’m going to give a ballpark figure of $150,000 a year average over those 36 years, which is turns out to be about the median salary for a statistician who doesn’t work in academia, according to the American Statistical Association. You’re at $5.4 million. That’s not counting 36 years of health insurance, 401 K and other benefits like not having a boss who is referred to as your “owner” , which I personally find kind of creepy weird, but you also have to consider you don’t get all the $5.4 million at once, either.

So, let’s present this to you:

  • You have a 1 in 10,000 chance of making $18.5 million
  • You have a 55 out of 100 chance of making $5.4 million.

You can only buy one ticket. Which lottery ticket do you buy?

Oh, by the way, did I mention you have a 90 out of 100 chance of making over $3 million ?

The coach’s point was that you may be dreaming about a spot in the NBA but you have a much greater chance of success in life if you spend your time in the math class instead of on the court. As a good friend of mine often says, “Too many people confuse wishes with plans.”

So, you may dream of slam dunks in the NBA but you would be a lot better off planning to take Calculus, several statistics courses and study a field like business, psychology, political science or epidemiology where you can apply those statistics.

You might think I don’t have any heart, that I have no idea what it means to dream of being a successful athlete. Actually, you’d be wrong. I ran track in college. I won the world championships in judo. Then, the next year, I went into a Ph.D. program and specialized in statistics because, well, I’m good enough at math to see what had the better probability of paying off in the future.

There are SO many ways to learn and use statistics. That’s another post, though. I’d best toddle off to bed since I need to catch a plane tomorrow after I go do a charity walk in the morning.

Early morning and snow, two things I hate the most. Well, life can’t be perfect all the time. I think I can prove that statistically.

Get started learning statistics with the Aztech Games series for iPad. The first game is available now and it’s free!



A couple of years ago, I get an email from Professor Douchebag (not his real name) that he is doing a study on women entrepreneurs and would like half an hour or more of my time. I’m in favor of research, so I schedule him in a week or two later when I have a spot on my schedule and he never calls. When I email him, instead of an apology I get this message,

“We had enough for our sample size but perhaps you would be interested in me consulting for you?”

I wrote him back and said I had no need of consultants that wasted my time and scheduling business owners for an hour, then being a no show with no notice is unprofessional and disrespectful.  Recently, I see his study has come out and the main conclusion is that what is holding women CEOs back is “lack of confidence”.  First of all, if the only women you interviewed were those who were able to give you an hour of their time at the drop of a hat, you did not have a very random, representative sample of women business owners.


Are you fucking kidding me?

I recently read a post by Hunter Walk, whose fund has funded 26% female founders versus the industry standard of 5%.  What that tells me is that if female entrepreneurs are less likely to believe that their firms will receive seed money or venture capital funds than male entrepreneurs do, it is not a lack of confidence but a realistic appraisal of the market.

I’ve written about this a lot on our 7 Generation Games blog

” it’s a self-fulfilling prophecy, when you constantly are telling women how much they suck, when you don’t give them a fraction of the same funding, when you act as if they are invisible and then say, “Look, they just aren’t cut out for this.” In fact, the women who succeed despite the lack of support, in fact, despite the constant disrespect and disregard, are some of the strongest, most resilient people you will ever meet.”

I was playing World of Warcraft last night and was a bit depressed by all of the ideas I got for making educational games more amazing that we just don’t have the funds to implement right now. Compared to the average for women-owned companies, we’ve done well. We have Windows games in the Microsoft Store, iPad games in the app store and even a game on Steam.

Spirit Lake Vill

We have done all of this with the most minute investor funding. We are still here thanks to three successful Kickstarter campaigns, our wonderful game players, funding from Small Business Innovation Research awards from the U.S. Department of agriculture and  less than 0.2% of the funds invested in each of such failed Silicon Valley darlings as Juicero , Jawbone and Luxe.

Do I think that women-owned companies receive less funding  than men? It’s not lack of confidence, it’s an absolute fact. Women are less likely to get funded and when they do receive funding the deals are for a lower dollar amount.

In Lots of outrage, little action by Maria Burns Ortiz, CEO of 7 Generation Games, spells it out perfectly, women are judged on their accomplishments while men are judged on their “potential” so the challenge for female CEOs is to get to those accomplishments with none of the outside funds given to men with “potential”.

I’m a world judo champion, Ph.D. and I founded a gaming company with some of the smartest people around and we have bootstrapped and begged and burned the midnight oil to keep this company going and growing. I don’t need more confidence, what I need is the same opportunity for funding at the same rate as my male counterparts.


If you’d like to buy our games, here are those links again

We have Windows games in the Microsoft Store,

iPad games in the app store and


even a game on Steam at 40% off this week

and on Amazon , under video games .

God spare me from the self-taught software developer who knows only the latest thing.


I’m not against the latest thing, whether it is react or ember or Python games on Raspberry Pi or whatever it is today. My objection is to the fallacy that it is the only thing or even the most import thing.  Let me enlighten you with why I am loathe to hire self-taught programmers no matter how many of the ‘most elegant’ techniques their example project showcases.

There are several things you learn as a grown-up programmer (which The Invisible Developer tells me I should not call myself because it sounds lower than software developer. Again, I ignore him. Do not be misled by this to believe he is not high on my list.  He just brought me a martini, with bleu cheese stuffed olives. )


What Self-Taught Programmers Aren’t Taught

If you taught yourself to code by some online coding school or watching videos or reading books from Safari O’Reilly that shows an admirable amount of motivation. If you already have some experience as a software developer and this is how you learned a new language, that’s great. Maybe we can hang out and work together. If, however, that is your ONLY source of knowledge and experience, probably not. There are a few things self-taught programmers are generally not taught simply because they are not working as part of a team.

  1. Testing. Testing. Testing. I said it three times because it was important. I think  I will say it again. Testing. Testing. This is why I need the martini. If you are developing an application, you need to test EVERYTHING. If I had a dollar for every time someone told me, “I tested everything but …” I would never need to seek investor funding again, I would just pull money from the piles in every room in my house. However much you think you need to test your software, you are wrong. The answer is, “More.” You need to test it on other machines besides yours. I learned this from SAS code that ran on Mac (yes, there was SAS on Mac a very long time ago) but not on Windows or on Windows but not on Unix. You can’t look down your nose at those people who aren’t running Windows 10 because that is only half of people who run Windows and less than 20% of the total market. SAS is actually a good starting point for learning this because it runs on a lot of devices with few changes but you do need to change the LIBNAME and FILENAME statements, for example. Similarly, we make games now that run on Mac, Windows, iOS and Android . At a minimum, you need to do a separate build , but sometimes you need to make major changes. For example, Android has some limitations on app size that iOS does not. Test whether your software installs. Test whether it opens. Test the most basic applications. For SAS, this would be creating a temporary data set, reading in data with a DATALINES statement and doing a PROC MEANS. For our educational games, it might be playing all the way through getting all of the answers correct. Test extreme cases. For S AS this might be merging several enormous datasets, applying user created formats, calling macros to manipulate the data and then performing a multivariate analysis of variance.

    For our games, it would mean getting every single problem wrong and quitting the game and logging back in many times, maybe after every problem. It would include entering completely illogical numbers, say, that you had picked 9,145,087 berries and and seeing if the program really tried to put over 9 million berries in the baskets.

    I’m sure you can think of some more extreme cases, but you get the idea.

    I can’t emphasize testing enough. The problem with someone who creates applications on his or her own is that person understands completely how the software is supposed to work. Real testing includes things like wandering off the path in a game with the path clearly marked, “just to see what would happen”. It is having people enter “as often as I can” instead of male or female for sex.

    I once asked someone how he managed to test a game where the image that showed the key for deciphering the message was missing and he said, “I knew what the image was supposed to be.” This was not the answer I was looking for.

  2. Debugging is most of your life as a software developer. Basically, you write code for a few minutes and then swear and debug it for hours. Once you have a little experience, you learn to test and debug as you go and never write huge blocks of code that you then find doesn’t work and you have to figure out where in there the bugs occurred. You will learn all types of tricks of the trade for debugging. These include, printing out the first few records of a data set to make sure it looks like you expect. With JavaScript it might be writing the value of a variable to the console. Either way, the point is the same, you are testing little bits of code as you go and seeing that the result is what you expected. You also learn to debug all the way through. With SAS, you might apply the statements you have written to a data set in the documentation and verify that you got the same results. With a game, you might collect all of the objects in a scene and then check that the variable recording the number of objects is equal to what you expect.

    In any program that you are writing, you learn to break it into modules and test each of those modules. So you are debugging it in chunks by writing out the values of some number both in small steps, say even after each statement if you are really running into problems, and also in medium steps, say, at the end of each S A S data step or procedure, or after the execution of each function.

    I’m not saying that self-taught programmers don’t debug their code because obviously they do. No one always writes code that works perfectly the whole time. What I am saying, is that if you are self-taught, you only know the debugging techniques that you have figured out for yourself, as opposed to picking up ideas from your colleagues.

  3. A third part of being a grown-up software developer often missed by those who are self taught is how to document the software. Comments are your friend. I had a colleague who made fun of me for how much I would put comments in the code but when the next year we had to do a similar project again I could turn to him and say, “who’s laughing now, bitches?” I have never met the programmer who enjoyed writing documentation. I have met a lot of programmers who were happy they had written it. if you are always chasing the latest thing, you might not be in that situation where you need to revisit something that you did a year or two ago. If you are not part of the team, you probably are not worrying whether some nonexistent team member can understand your code. On the contrary, you might be trying some really cool new ideas just because they’re interesting. I’m not against that, in fact, I completely understand. However, you need to document those cool new things. And if you take the attitude, “well, everyone should be expected to know the function call to integrate Lua with PHP”, come here little closer so I can slap you.

Here’s why being part of a software development is usually a crucial aspect of your career progress – all of the things I mentioned, most people don’t really want to do. Testing isn’t nearly as fun as writing code. No one likes to write documentation. Everyone knows that debugging is crucial but it usually seems at the time as if putting in all of those statements to check every single variable’s value after every manipulation is so time-consuming when you are just sure it was correct anyway. When you’re on a team, you can’t get away with cutting corners and skipping the not fun parts nearly so much. You also realize how crucial those parts are when other people on the team have no idea what in the hell you were doing when you wrote that function or macro or nested do loop.

Sorry, but I don’t think a weekend hackathon is any substitution no matter how many prizes you won. Not unless you had to return to the same hackathon six months later and update the project with a completely new set of people.

I don’t want to leave you all depressed, though. So, I do have two pieces of advice. For the debugging part there are plenty of software conferences you can attend, and find sessions on tips for debugging software. you may also meet people at those conferences that you could end up working with on a team for some project interests all of you.

Blogging – is a great way to document what you have been doing. On this blog, and my other company blog, I often write down what ever I have been working on lately just so I remember when I run into a similar problem six months down the road. You’d be surprised how often I Google a question and one of the first answers that pops up is a blog post I wrote years ago.

Speaking of  games – check out Making Camp, you can get it here for free. Play it and learn stuff because maturity is overrated.


If you want to learn even more stuff, you can get a bilingual version of Making Camp for your iPad for only $1.99 and brush up on your Spanish like you always said you were going to do but didn’t

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.

  1. Switches sound file played from English to Spanish
  2. Switches text from English to Spanish
  3. Takes you to the bonus game when you click on the sound bubble
  4. When the sound file ends, replaces the talking gif with a static image  and shows the arrow to continue.
  5. 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")) {;
} else {;
else {
audio_e2.src = "sounds/" + scene + ".mp3";;

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.


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.

Speaking of  games – check out Making Camp, you can get it here for free. Play it and learn stuff because maturity is overrated.


If you want to learn even more stuff, you can get a bilingual version of Making Camp for your iPad for only $1.99 and brush up on your Spanish like you always said you were going to do but didn’t

blocksSo 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:

  1. Programming concepts – You need to understand scope, do-loop, arrays, functions
  2. Data management – The thousand ways that users can enter data, and how to keep it from screwing up your results
  3. Working in a software development team – this is the part “self-taught” programmers are often not taught – documentation, testing and debugging
  4. 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
  5. 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.


Data scored ;
set mydata.data2013 ;
array ans{70} q1- q70 ;
array correct{70} c1 – c70 ;
array scored{70} sc1 – sc70 ;


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”,

var things_name = [

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 of
variables is then referenced in the DATA step by the array name. The variables in the array are called the “elements”
of the array.
Every word of that applies in JavaScript except for “of the same type”. In JavaScript you can have mixed type arrays and if SAS would add that, it would make me very, very happy.
Arrays are a fundamental concept to any programming language, so mastering that concept is a step forward.
Truly understanding variables is another foundational idea – not just that they are not constants, but the concepts of type, format and scope – but that is a whole different post and The Invisible Developer is reminding me it’s almost 11 pm on Sunday night, so that will be my next digression.

Speaking of Making Camp, you can get it here for free. Play it and learn stuff because maturity is overrated.


If you want to learn even more stuff, you can get a bilingual version of Making Camp for your iPad for only $1.99 and brush up on your Spanish like you always said you were going to do but didn’t.

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. 

Winning on the ground cover

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.

Support my day job AND get smarter. Buy Fish Lake for Mac or Windows. Brush up on math skills and canoe the rapids.

girl in canoe

For random advice from me and my lovely children, subscribe to our youtube channel 7GenGames TV


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:

typical career path

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.

My career path


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.


Support my day job AND get smarter. Buy Fish Lake for Mac or Windows. Brush up on math skills and canoe the rapids.

girl in canoe

view from plane windowLittle known fact (because, seriously, how would you know) , I write a lot of code while sitting on a plane and I can’t always connect to the Internet.


Sometimes, when I copy and paste my code into SAS Studio, it doesn’t work.

if compress(q23) = “3/4” then q23 = “.75” ;

Just so you know, this does not work because some programs like Word, or even TextEdit on the Mac will replace quotes with some swirly shit (see above) that SAS and other languages don’t read as quotes.

This article from the University of Michigan gives some hints on how to prevent or fix this problem.

How to tell if your quotations are a problem

SAS Studio is color-coded.
Note that the first two lines have the values shown in purple.

color coded

The next two lines don’t. If you look closely, those are the evil curly quotes. If you realize this, you can tell at a glance if there is a problem with your code.

Getting rid of text

Okay, I replaced the evil curly quotes, but I still have a problem. The questions are things like,

“What is the area of this shape in square feet”, and let’s say the answer is 240 .

Students answer all kinds of variations of that, like :

  • 240 square feet
  • The answer is 240
  • 240 sq ft

All of these answers are correct but if I just compared them to 240,  they would not be equal and be marked wrong. Enter the COMPRESS function.


The above statement will remove all alphabetic characters from the answer and return just numbers.

The COMPRESS function has three parts –

  • the source, which is the variable you want modified, in this case, Q3,
  • the characters you want added or removed (the default is removal),
  • an optional modifier

In my case, I used the modifier ‘l’  – that is a lower-case L, not a number 1 – because I wanted all of those letters removed if they were lower-case, too. So, I don’t have to type all of the letters of the alphabet twice.

Getting rid of special characters

You can also use the COMPRESS function to get rid of special characters. Say the question is “If tickets are normally $100 and tickets are 50% off, how much does it cost Cassandra for a ticket to the Dead Fleas concert?” Students will enter answers like, $50 or 50.   To get rid of the $, simply do this:

q1 = compress(q1, ‘$’) ;

When I’m not teaching statistics or writing about SAS, I’m making video games. We’re doing a Kickstarter campaign to make our bilingual games available everywhere and if you backed us, that would be AMAZING ! Plus you will get cool prizes.

I read a comment on line saying SAS probably would not disappear as an option for statistical analysis because “it’s good when you need to do a lot of data manipulation”.

I wonder what world those people live in that data comes all cleanly packaged and whether they have unicorns there.

Back on Planet Earth, I have a data set that has multiple records for the same date for the same students.  For some reason, the data were being sent at the end of each screen at one site, instead of at the end of the test. So, the data look like this:

kat123 4 5 18 11   2017-04-23 17:39:26

kat123 4 5 18 11   42 17 8 0 1 2017-04-23 17:41:12

and so on.

The students also took a post-test, months later, so …

I need the last record for each date, but my data has date and time

You might think doing

testday= datepart(date_entered);

would work and it would except for the fact that

My date is saved as a character format! What do I do?

You can read some suggestions here in SAS communities

I could not find

2016-02-03 19:41:26

and I spent a good hour trying different methods to get this to work. I will spare you the details and maybe I could have gotten some method to work (no, whatever you are considering, I probably already tried). However, this occurred to me …

Do you really need to change it to a date format?

In this case, I was not doing any calculations with the date value, I simply needed the day part as a unique value.

I could just use the first 10 characters like this

day_of_test = substr(date_entered,1,10) ;

If you figured this out in the first sentence or two you are probably laughing by now (shut up).  Yes, it doesn’t matter if it is formatted as a date or not. So, that is what I did.  After creating a variable that is just the day of the test, I sorted by username, day of test and date entered (which included the time value). Then, I read in the data using the BY statement in the Data step so there would be  last. variable created that is whether or not this is the last record with that value in the BY group.  I output the last record for each day by using a subsetting IF statement.

Data fixdata ;
set mydata.aztech_pre ;

*** CREATE day_of_test variable as characters 1-10  ;
day_of_test = substr(date_entered,1,10) ;

*** SORT by username, day of test and date entered (including time);
proc sort data=fixdata;
by username day_of_test date_entered ;

*** DATA step that only saves last record ;
Data mydata.aztech_pre ;
set fixdata ;

***  BY statement to define that the data is by username and day_of_test ;
*** NOTE:  If you didn’t do the PROC sort first, this won’t work. For shame! ;
by username day_of_test ;

if last.day_of_test  ;

So, that worked perfectly. I included my missteps because it is easy when you are a newbie to believe that everyone is smarter than you and never makes bonehead mistakes. Not so. We all make them all of the time. The important thing is, figuring it out in the end. Sometimes the easy way is not so obvious.

Or, maybe it is and I’m a bonehead. Either way, it worked. Now on to step 2.


When I am not writing about SAS, I’m making games that teach math, social studies and language.

Check them out.

screen shots from our games

A while back, I wrote a post on getting your Excel data into SAS Studio the quick and easy way. However,  I hear you saying,

What about ME? What about MY needs? What if I don’t want my data written to the working directory? What if my file has the names at the top and I want to keep those names?

First of all, open a program file and run some code that assigns the LIBNAME to the directory where you want your data stored. It should look like this but whatever is in the quotation marks should be where your data are stored.

LIBNAME mydata “/courses/d1234566789” ;

Second, upload your Excel File


Under FILES, select the folder where you would like your data stored. Click on the UPLOAD FILES button (the arrow pointing up at the top of the screen) and then click CHOOSE FILES to go to where the file is stored on your computer. Select that file, click the button on the pop-up window that says UPLOAD. Now you have your Excel file, uploaded but you want a SAS file.sasExcel2

Go under TASKS and UTILITIES and click the arrow to select UTILITIES and then select IMPORT DATA.



On the right, you’ll see this big window that says DRAG AND DROP YOUR FILE HERE.

file list

In the left pane, open the FILES directory and go to where you saved your Excel file. Drag it into the window. Once you’ve done that, this wi If you stopped here, you would have the file written to the working directory, and named import.

import option

If you want to change that, click the button that says CHANGE.

changing default name in boxes

This pops up. Don’t see the directory you want? Did you run the LIBNAME statement at the very beginning of this post to assign a library reference to that directory? For shame! You think I just make this stuff up? Go back and do it now.

Okay, should you be concerned that your library name is greyed out? No, you should not. That just means you cannot change the name of your library reference here. If you wanted to change that library name from “mydata” to “yourdata” you’d have to do it in the LIBNAME statement.

Type the name you want for the data set. Do not forget to click SAVE or you may as well have skipped this step.

Click the little running guy at the top of the window.

Before you go, notice that SAS also generates code for you. If, like me, you anticipate that your data may change and you may need to do this again, you can copy and paste the code generated by SAS and save it in a program file. Run it again to recreate your data set. How likely is that to happen?  Well, it happened to me today when I inadvertently (that’s a synonym for “stupidly”, right?) wrote over this exact data set.

/* Generated Code (IMPORT) */
/* Source File: az_pretest.xlsx */
/* Source Path: /home/annmaria.demars/data_analysis_examples/data2017 */
/* Code generated on: 7/31/17, 6:09 PM */

FILENAME REFFILE ‘/home/annmaria.demars/data_analysis_examples/data2017/az_pretest.xlsx’;



Okay, there you go. With a few clicks, your Excel file is accessible in SAS Studio as a SAS data set and you have a copy of the code that did it.

Next post we’ll start whipping that data into shape.

When I am not writing about SAS, I’m making games that teach math, social studies and language.

Check them out.

screen shots from our games



← Previous PageNext Page →