It’s mid-afternoon. Day 2 of the PRG2 class. Students return satiated from lunch. Some slipped into this course without taking PRG1 so they missed out on some basics. I’m trying to explain how SAS thinks. I use slides, draw pix, do everything except break into dance to get their attention. I can’t blame them –sweltering July heat combined with a post-lunch sense of contentment can make anyone’s eyes glaze over as I mention the PDV.
‘PD what?’ exclaims a mother of three, thinking no doubt of Parent teacher days.
‘Prune Dwarf Virus’ cries out a research scientist rubbing his hands with glee.
‘Petroleus de Venezuela’ shouts the oil tycoon.
‘Police department’ barks the ex-cop in class!
‘No, No, No, it’s the SAS PDV’, I implore trying not to despair.
I realize a change of strategy is required and switch direction. As I mention shopping, a student sits up, then another. Soon the whole class is engaged and nods in understanding. So I thought I’d share with you how SAS thinks with a simple IKEA analogy.
What’s my justification to spending hard earned pay dollars? The economy of course! I’m sure you’ll agree we all have to do our bit as conscious citizens. How can the wheels of the economy churn to come out of recession without our able bodied help?
As someone who tries (but ruefully admits doesn’t always succeed) to smart shop, I’d be amiss if I didn’t mention IKEA. Can you compare the two? I like to think so. So before we get into SAS’ head to see how it thinks and works, let’s talk IKEA first.
How do I put together an IKEA Bookshelf once I’ve brought it home? I would break it down into 2 phases:
- Open the book of instructions & translate it to make sense to myself
- Clear out a space in my living room to do the assembly work
- Count the nuts and bolts to make sure I have enough of them (if any are missing I’ll have to call the IKEA support line).
- Build the outer shell of the bookcase where I’ll lay in shelf by shelf during assembly
- Lay out shelf by shelf on the outer shell respecting any special instructions
Now to SAS. How does SAS process and think to build your SAS dataset? Also in 2 phases:
- Translates your code to machine language
- Creates the Program Data Vector (PDV)- don’t be frightened by this name, it’s just a temporary space (like your living room for shelf assembly) for doing the work
- Scans syntax for any errors and complains in the log if it finds any
- Builds a descriptor of your output dataset where SAS reads in your data record by record during execution
- SAS reads in your data row by row into the descriptor of your output data set using any special instructions in your code
The joys of shopping! Do you see the similarity between my plain and simple IKEA shopping and highly evolved SA? So don’t let the PDV faze you in the future. Next time you shop-till- you-drop at IKEA, you just might find yourself breaking into a smile. I’m guessing it’ll probably be because you know without a doubt
that SAS breaks down the work just like you do in 2 phases -compile and execute.
This is a simple interpretation of data step processing. For more in-depth information, check out the SAS Programming1: Essentials (PRG1) course page.