Bad words in SAS - PG rating

Picture this – a student grabs the Programming 1 textbook, scans it quickly seemingly searching for something specific, and shakes his head indicating an unsuccessful search. He plants himself smack dab in the front row, looks me squarely in the eye, raises one eyebrow quizzically and says, “Bad words?”

I must confess I’ve encountered my fair share of unusual questions, but this one just floored me. It broke every code in the instructor rule book which says-steer clear of 3 topics in the classroom:

  1. anything to do with politics
  2. religion
  3. sports

Technically his question didn’t fall under the 3 forbidden categories of student-land that we seldom wander into.

Blushing, not knowing what to say, I stammered “Sorry, Wwwhat?”

Student, “Oh, come on, you’re teaching a language. Whenever I learn a new language, the first thing I do is learn the bad words, makes it easy for me to know the rules when I know what not to do”.

Me, “Never thought of SAS rude words, but I’ll give it a try”. I have to admit shamefacedly I did end up teaching the class a lot of bad words! Remember my post has a PG rating!!

Much later after class was over, when I sat back to review the student evaluations, this student’s question surfaced in my mind. In this blog post I’ll try to coherently answer the question:

What are bad words that SAS doesn’t like?

The SAS language recognizes 5 types of errors. Here are two types with examples of each:

Syntax error

  • Missing semicolon—like you end a sentence in English with a period, SAS statements end with a semicolon. Missing one makes SAS complain in the log.
  • Commas are another no—unlike SQL, SAS prefers spaces as the separator between words
  • Mismatched quotations—these cause your data step to run indefinitely

Data Error

  • Bad Data—you’re trying to read in character data in a numeric variable or you’re trying to sum a character variable – in the example below model is character and the SUM statement fails resulting in an ERROR thus SAS stops processing the step


How does SAS complain?

There is no ambiguity or beating around the bush with SAS. What you see is what you get. Likewise when you talk rudely, SAS will complain. To correct your manners just check the log.

You’ll see one of these:

  1. A warning-in green, indicating SAS understands, despite the poor language, and it makes an assumption on your behalf and carries on. It’s not a bad thing.
  2. An ERROR- You can’t miss the bad words highlighted in red which SAS doesn’t recognize at all. Despite any trash talking, SAS retains its politesse. It even goes as far as to address foul language with the gentle name of ‘ERROR’. When you trash talk, SAS shows you the hand and won’t go any further. It completely stops processing your code.  This is bad news.

How can I place closer attention to these Warnings/ERRORS during Run time?

Depending on your type of error, you might try out one of these techniques:

  1. Always check the log first – a golden rule to follow that every Programming 1 class I teach hears about a lot
  2. PUTLOG statement –puts informative messages that you specify in the log.The PUTLOG statement is also helpful when you use macro-generated code because you can send output to the SAS log without affecting the current file destination.
  3. Data step Debugger- you go behind the scenes and check out values of variables for each observation during execution.  I hope to write my next blog on the inside workings of SAS and will elaborate on execution then.

 You might be interested in checking out this useful paper .  

 Now you know some choice curse words in SAS … which I hope you’ll refrain from using, in your best interest.  I’d love to hear about other times that SAS has complained.

tags: data step, sas programming 1: essentials


  1. Posted October 12, 2011 at 11:53 am | Permalink

    Nice post and good resources for dealing with error logs.

    When I was an instructor, I had to add 'barbeque' to my list of forbidden topics (previously just politics and religion) after two students nearly went toe-to-toe debating the merits of Eastern North Carolina and Western North Carolina styles.

    • Charu Shankar Charu Shankar
      Posted October 27, 2011 at 1:27 pm | Permalink

      Wow, that's close to another comment that an instructor faced when talking about the blue sky--someone else started talking Sports animatedly. Thanks for reading Mark

  2. Posted October 18, 2011 at 5:20 am | Permalink

    silent failure occurs rarely, but significantly when using END= on an INFILE DATALINES statement.
    Quite painful if using END= to signal end of data when you want to create macro variables (like how much has been read).
    Although a Restriction is documented there is neither NOTE nor WARNING created when END= is used on INFILE DATALINES.

    • Charu Shankar Charu Shankar
      Posted October 27, 2011 at 1:44 pm | Permalink

      thanks /BEWARE for this note. Appreciate your writing in.

  3. Star Abernethy
    Posted October 24, 2011 at 9:45 am | Permalink

    What a clever post and I learned something as well....which is quite interesting since I am no where close to being a programmer.

    • Charu Shankar Charu Shankar
      Posted October 27, 2011 at 1:42 pm | Permalink

      Glad this post helped understand SAS some more. Thanks for writing in, Star.

  4. Steve James
    Posted November 7, 2011 at 3:41 pm | Permalink

    Nice post. SAS often complains about my use of the language in too many ways to articulate, but two cases which I do quite frequently are the following:

    1) Ending a data/proc step with URN instead of RUN. Thankfully I usually correct this before SAS has a change to complain, but my fingers haven't quite always learned not to say it.

    2) Failing to add a percent sign when doing a macro do loop as in

    %do i = 1 to 10 ;


    • Charu Shankar Charu Shankar
      Posted November 24, 2011 at 11:50 am | Permalink

      true, lucky our mouthiness gets caught by SAS in the log :) thanks for taking the time to write.

  5. Anthony Williams
    Posted November 7, 2011 at 6:48 pm | Permalink

    how about some good words ? imaginative

    • Charu Shankar Charu Shankar
      Posted November 24, 2011 at 11:50 am | Permalink

      will do, stay tuned for an upcoming episode of good words :) thanks for writing.

  6. ananth
    Posted June 28, 2013 at 10:05 am | Permalink

    Nice and good input for the learners

  7. anantha nagaraju
    Posted June 28, 2013 at 10:06 am | Permalink


One Trackback

  1. [...] you learn first in SAS? That was the question posted to SAS Instructor Charu Shankar, who wrote Bad words in SAS - PG rating on the SAS Training Post last week, as a [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>