Explaining analytics? Maybe you should think about the narrative

explaining_analyticsI continue to find the concept of explaining analytics through storytelling intriguing. As I have written before, at first blush this did not seem immediately clear to me. The advice to use storytelling appeared somewhat vague, trite and without substance. More importantly, it seemed to conflict with the rigor required in analytics. At best I found it to be garden-variety advice somewhat like, “avoid using jargon.” Certainly, it is a fine idea to avoid the use of words your audience does not understand, yet the advice (avoid jargon) gives you no indication of what to do. I will leave avoiding jargon as a topic for another day. Instead, let’s take a deeper look at the storytelling recommendation in order to make it more concrete.

I am always appreciative of explicit recommendations – clear guides as to what to do.  Additionally, I am always grateful, as I’m sure most of you are, when the recommendations are based in research.  I recently ran across a rather interesting study that meets these requirements.  It addressed the storytelling approach used in scientific journals.  Clearly the approach of writing in such journals is to be objective and circumspect, but as presented in the work “Narrative Style Influences Citation Frequency in Climate Change Science,” authors Ann Hillier, Ryan P. Kelley and Terrie Klinger present a case for using a readable, interesting narrative style to increase citations.  If you are in the scientific world being published is desirable, being cited is even better.  Increasing the number of citations certainly sounds like a positive goal.

Most of us in Analytics are not looking for publication in scientific journals, our audience is more local.  However, we do want our audience to remember our work and use it.  That is our form of citation.  If you hear a decision maker repeating a finding from your study, you have been cited, you have succeeded.   To hear something frequently referred to, week after week, may be one of the most satisfying results of your work. To see the work implemented is even more satisfying.

In this study the authors defined narrative style through six quantitative indicators.  They truly represent explicit advice, clearly have a storytelling aspect to them, and they are found in total to give a positive correlation to citations. (As a side note, the study presents an excellent example of the use of principle components to deal with the co-linearities of the predictors.)

The six indicators are:

  • Setting:  A description of where and when the event take place.
  • Narrative Perspective:  The use of first person pronouns.
  • Sensory Language:  Language appealing to the senses and emotions of the audience.
  • Conjunctions:  Connecting words and phrases to that bind a narrative
  • Connectivity:  Referring back to previous sentences or passages, again indicative of a narrative form.
  • Appeal:  Making an explicit appeal or a clear recommendation for action.

Read More »

Post a Comment

How do teenage boys eat so much, and stay so thin?

"They'll eat you out of house & home! Their food bill will put you in the poor house! ... And they never gain an ounce!" - That's what my friends say about their teenage sons. They're probably exaggerating a little, but since it's a recurring theme, there's probably some truth to it, eh? Let's have a look at the data...

I did some web searching and found an article on fivethirtyeight.com related to this topic. It had a graph showing the number of calories we need per day, based on age and activity level. Here's their graph for Males.

calories_orig

My biggest complaint with the graph is that it is very blocky. True, the data itself is somewhat blocky, but we intuitively know that you don't suddenly go from needing a certain number of calories, to needing several hundred more (or less) - the change is probably a bit more smooth/continuous. The original graph uses a step interpolation, where the line stays at the current level until it reaches the next data point, and then goes straight up/down to it (like stair steps).

bad1     bad2

Rather than a step interpolation, I would recommend using a simple join interpolation, connecting each data point with a straight line. Now, rather than the Moderate and Sedentary lines touching in several spots, they have a slight gap between them, and show smoother transitions. I think the graphs are much easier to read, and more visually pleasing. Here are the same sections of the graph, using a simple join interpolation rather than a step interpolation.

good1      good2

Below is my complete version of the graph, using data from a table I found on the usda.gov website. Here are a few of my improvements over the original graph:

  • I add a title describing what's in the graph (so you don't have to read the entire article to know what it represents).
  • I use the join interpolation, which produces smoother transitions than the step interpolation.
  • I add a reference line grid, so you can more easily determine which age and calorie range corresponds with which section of the graph line.
  • I leave out the average gray bars/area - there are just too many unanswered questions in my mind about what makes up the average.
  • I make my line/color labels easier to read.

According to this data, active young men in the 16-18 age range need 3200 calories per day. That's 1000 calories a day more than a less-active middle aged man - that would certainly explain the phenomena my friends with teenage sons have mentioned! Where are you on this graph? Does it sound about right? I remember that at ages ~26 and 45 I had to start cutting down on snacks and desserts, to keep from gaining weight - that's right in line with what these graphs are saying.

calories_needed_male

And just in case you're curious, here's the calorie graph for females. Note that rather than auto-scaling the y-axis, I plot it to the same scale as the male graph, so the two graphs can be compared.

calories_needed_female


So, what's your favorite high-calorie indulgence? Have you ever splurged on a dessert that contained your whole day's worth of calories?

I asked my friends if they had any high-calorie examples, and here's what they (Samantha, Eva, Becky, Mubarra, Claudia, and Beth) came up with - hungry yet? :)

dessert5bdessert2 dessert1dessert4dessert3

banana_pudding

Post a Comment

Where does Girl Scout cookie money go?

Here in the US, it's Girl Scout cookie season. This is when you get to spend a few bucks on cookies, break your New Year's resolution about losing weight ... and feel good about it, because the money's going to a good cause. Or is it? - Let's break down the numbers and see!

Before we get started, here's a fun photo from my friend Matt. He posted this on Facebook, and it's how I knew the cookie season was upon us (note that these are cases of cookies, and each case contains several boxes!) I'm not sure whether he's planning to eat them, or sell them - knowing Matt, I'm going to assume a little bit of both. :)

matts_cookies

In a previous blog, you might recall that I combined analytics and Girl Scout cookies by creating a SAS map showing which of the two bakers made the cookies sold in each county in the US.

In this blog post, let's get down to dollars and cents. Being a middle-aged guy and working a desk job, I try to not eat sweets & snacks, because I don't want to become one of the almost 50% of Americans who are considered obese. So, when my local Girl Scout troop sends representatives to sell me some cookies, I'm thinking about just donating some money instead. But how much money should I donate, to compensate for the cookies I didn't buy?

My first guess was that on a $4 box of cookies, the Girl Scouts probably makes $1 profit. But after I checked into it, I found out I was wrong ... way wrong. According to the Girl Scouts FAQ page, they actually make 65-75% profit, which means that about $3 from each $4 box goes to the Girl Scouts.

Here is it, laid out in graphical form (hmm ... maybe I should have used a pie chart? ... I wonder if there's such a thing as a cookie chart?)

girl_scout_cookie_profit

And the FAQ on their web page says most of the profit goes to the local council (which is typically a group of counties within your state), and a smaller amount (10-20% of the profit) goes to the troop (that's the local club in your city/area). I was curious exactly which council our local Wake county NC Girl Scout troops were in, so I did some Google searches looking for council maps. I found some maps for other states, but none for NC. I found a Wikipedia page with lists of counties in each council, but text lists of the 100 counties just didn't form a good mental picture for me. So I put together some SAS code to plot the data on a map. Now I can quickly see that Wake county is in the Coastal Pines council (the light yellow color in the map below).

girl_scout_councils_nc

 

But perhaps all this data visualization is just my attempt to go on a tangent, instead of answering the real question. How much money should I donate, instead of buying cookies? Well, if you were going to buy 4 boxes of cookies for a total of $16, I guess if they make 75% profit then $12 would be a fair donation, right? But what about the intangible factors (ones that can't really be graphed)? Here are some other factors to consider, based on info from their FAQ page:

When you buy Girl Scout Cookies, you power amazing adventures and life-changing opportunities for girls—from trips to our nation's capital to community projects, from summer camp to charitable donations. The more cookies you buy, the more you help today’s girls transform into tomorrow’s G.I.R.L.s (Go-getters, Innovators, Risk-takers, Leaders)™.  And it's about the skills a girl gains from interacting directly with you, the cookie customer! It's about the experience of running her very own cookie business, working with others—and building a lifetime of confidence as she learns five skills (goals setting, decision making, money management, people skills, and business ethics) essential to leadership, success, and life. Girl Scouts also earn badges (such as Cookie Business and the Financial Literacy) and program credits for selling cookies.

I don't think donating money will accomplish many of those things in the same way that buying the cookies would. And then there's the sense of accomplishment - if you were a Girl Scout selling cookies, would you rather tell your friends "I sold 20 boxes of cookies" or "I got a $60 donation"?

When I started this blog post, my goal was to show that it would be better to donate money than buy cookies. But after studying the data & details, I've convinced myself of the exact opposite - I recommend that you buy the cookies! If you don't want to eat them, I'm sure your co-workers will be happy to help you with that! :-)

While we're on this topic - what's your favorite Girl Scout cookie? (now, or in the past)

 

Post a Comment

Prius isn't the highest-mpg hybrid in 2017!

For many years, the Toyota Prius was the hybrid with the best mpg - but in 2017 that's changing! Let's examine the data ...

For analyses like this, I have found the fueleconomy.gov website to be a wonderful source of information. In recent years, they've even made all their data available in a csv file that's easy to download! I wrote some SAS code to import their csv, and then I was off to the races (figuratively) to create some graphs.

In the 2016 data, the Prius Eco was the vehicle sold in the U.S. with the best mpg (53.3 hwy / 57.8 city)

In the 2017 data, the Prius Eco is still up there at the top of the midsize cars graph. And the Prius c is at the top of the compact cars graph.

gas_mpg_2017_midsize_cars

gas_mpg_2017_compact_cars

But there's a new vehicle coming onto the market in 2017 that gets better mpg than all the Prius models ... and surprisingly this vehicle is in the "large cars" category! It's the Hyundai Ioniq Blue, which should start selling sometime early this year (2017). Its EPA ratings are 59.4 mpg highway and 56.5 mpg city!

gas_mpg_2017_large_cars

Will the Ioniq hybrid really get that many mpg when people start driving it? - Time will tell! As you might recall, when the C-Max hybrid first came out in 2012, Ford claimed EPA mpg numbers that beat the Prius, but later had to revise them to lower-than-Prius levels.


And now for a bit of car-related fun ... Two of my co-workers, Mary & Thelma, have a dad who restores and customizes Corvettes. I've seen his work, and he puts out some truly spectacular cars. Here's a picture of an example they loaned me for my blog - it's a 1975 Corvette (customized to be a station wagon, using the Greenwood kit) with a 454 cubic inch 8-cylinder engine. 454 cubic inches is over 7.4 liters - by comparison the Prius gasoline engines are 1.5 & 1.8 liters. They estimate this Corvette gets about 15 mpg ... but who really counts mpg on a hotrod Corvette, eh?!?

corvette_wagon

 

And here's a car my buddy Richard has owned for 30 years. It's a 1973 Plymouth Valiant, with a slant-6 motor and automatic transmission. The engine was converted to the 2 bbl Super Six intake system. The transmission is from a Volare station wagon, and it has a 245 rear differential from a Highway Patrol Dodge Dart. He claims he averaged 37 mpg from NC to IL and back.

valiant_richard

 

So, what's the favorite vehicle you've owned, and what mpg did it get? :)

 

Post a Comment

What to do in Orlando, during SAS Global Forum!

They say "a picture is worth 1000 words" - and I think it might be more like 2000 when it comes to planning out fun/interesting things to do in  a new city! I'm going to the SAS Global Forum (#SASGF) conference in Orlando this year, and I was wondering where the conference hotel was in relation to the fun things to do in the area. So, of course I plotted it all out on a map, using SAS! You might enjoy seeing how I created the map, and you might find the map itself useful if you ever visit Orlando.

First, I compiled a list of things to do in Orlando (using web searches & asking my friends for recommendations). I estimated a latitude/longitude value for each thing, and read them into a SAS dataset using code like this ...

orlando_sign_code

I then created a scatter plot of the locations, and suppressed all the axes (note that the yellow marker is the main conference hotel) ...

orlando_attractions

Next, I wrote SAS code to download the 16 slippy map tiles (16 separate png images) at zoom level 12 for the area of interest, and I annotated the 16 tiles behind the scatter plot.

orlando_attractions

And now for the cool part ... In my maps, I often like to add a little graphic element to let people quickly/easily know what the map represents. In my Las Vegas map, I created my own version of the famous 'Welcome to Las Vegas' sign. The 'Welcome to Orlando' sign isn't quite as fancy, but I thought it would be a nice touch to add to this map. I could have found an image of the sign, and annotated the image ... but where's the fun in that?!? So I decided to create my own version of the sign using simple annotated graphical shapes and text.

First, I created a blue box.

orlando_sign1

Then I added some blue bubbles with slightly smaller lighter-colored bubbles inside them.

orlando_sign2

Then, I overlaid a box using the light color, followed by a slightly smaller blue box.

orlando_sign3

Then a couple more blue bubbles, so fill-in some on the left and right sides.

orlando_sign4

Adding some text almost finished the sign! ... But it still needed a little something to set it off!

orlando_sign5

And that special something is the skyline. I got a skyline image, and modified it in Photoshop Elements, making the background transparent and the buildings the same color as my sign. I then used annotate to add the image seamlessly in the desired location. Wow - did you know SAS could do all that!?!

orlando_sign6

I think the welcome sign really helps spice up an otherwise boring street map! Click the map image below to see the interactive version, where the markers have mouse-over text (and they drill down to a Google search on each attraction).

orlando_attractions

What are your favorite things to do in Orlando? Did I leave out anything?!? Feel free to leave a comment ...

 

Post a Comment

11 new SAS Press titles for 2017

Whether your resolution is to get SAS certified or to become a more advanced SAS programmer, we’ve got you covered with these new titles and upcoming SAS Press books, many of which will be making their bookshelf debut at SAS® Global Forum 2017 in Orlando, FL!

Want to be notified when a new book becomes available? Sign up to receive exclusive discount offers and information about new books delivered right to your inbox.

SAS Press Titles for 2017
1  -  SAS(R) ODS Graphics Designer by Example: A Visual Guide to Creating Graphs Interactively by Sanjay Matange and Jeanette Bottitta illustrates the features of the ODS Graphics Designer. The designer application lets you, the analyst, create graphs interactively so that you can focus on the analysis, and not on learning graph syntax. This book will take you step-by-step through the features of the designer, providing you with examples of graphs that are commonly used for the analysis of data in the health care, life sciences, and finance industries.

new-sas-press-titles-for-2017_02
2  -  Implementing CDISC Using SAS®: An End-to-End Guide, Second Edition by Chris Holland and Jack Shostak updates the first comprehensive book on applying clinical research data and metadata to the 2017 CDISC standards.

new-sas-press-titles-for-2017_03
3  -  An Introduction to SAS® Visual Analytics: How to Explore Numbers, Design Reports, and Gain Insight into Your Data by Tricia Aanderud, Rob Collum, and Ryan Kumpfmiller shows you how you can use SAS® Visual Analytics to transform your complex data into knowledge with meaningful, customized visualizations. This book gives you the ability to access, prepare, and present your data from anywhere and will help anyone learn to make sense of complex data, leading you to smarter, data-driven decisions without writing a single line of code – unless you want to! (1st Quarter 2017)

4  -  SAS® Viya™: The Python Perspective by Kevin D. Smith and Xiangxiang Meng explains how to use Python to drive SAS Viya by directly connecting to the back-end analytics engine: CAS. CAS (Cloud Analytic Services) is a fault-tolerant, high-performance analytic platform that can be installed in many environments (desktop, computing grid, cloud). It is used by various SAS applications, but also has an API accessible from languages such as Java and Python. (1st Quarter 2017)

new-sas-press-titles-for-2017_04
5  -  Business Survival Analysis Using SAS(R): An Introduction to Lifetime Probabilities by Jorge Ribeiro shows professionals with little modeling experience how to apply survival analysis to the world of business. The examples in this book show how to apply models for people with low modelling experience, and present techniques for analysts in a way that avoids high-level theoretical considerations. Graduates of economics, business, and marketing programs, as well as analysts who work in areas such as credit risk, will benefit from this book! (1st Quarter 2017)

Read More »

Post a Comment

American English: Where to use 'yall' versus 'yinz'

If you do much traveling in the United States, you're bound to hear a few words and expressions that are unique to certain areas. Well y'all get ready, because I'm fixin' to analyze some of those words for ya!

I recently found a really neat web application called The Great American Word Mapper that lets you enter words, and see maps of where those words were used most frequently in Twitter posts. It's pretty cool, and almost addicting! Here's an example showing the two words I found most interesting - yall and yinz:

word_mapper

And as with any cool map, I felt compelled to try to create a similar one with SAS software!

Fortunately, they provided a link to their data on a Google drive, which made my endeavor a lot easier. They provided a separate csv file for each letter of the alphabet, and each level of smoothing (none, low, med, and high). Since yall and yinz both start with the same letter, I only needed the 'y' data files, and I decided to go with the 'medium' smoothed data, since those maps looked the best to me. I used the DMS SAS File->Import wizard, which wrote me a bit of Proc Import code that imported the data quickly & easily. I was then able to plot the data fairly easily using Proc Gmap. Here are my SAS maps showing the smoothed data for yall and yinz:

wordmap_yall1

wordmap_yinz1

Here are a few changes (hopefully improvements) in my version of the maps:

  • I added titles/text to explain more about what is represented in the map, and where the data came from.
  • I made the state outlines darker, and left out the county outlines, shifting the focus from counties (which most people aren't familiar with) to states (which most people are familiar with).
  • I leave out the city labels, because they obscure parts of the map and I think the state outlines suffice.
  • I added html mouse-over text to show the state names (click the map image snapshots above, to see the interactive versions with the mouse-over text).

I liked the original maps, but I like my versions even better! The 'yall' map showed just about what I expected - common usage throughout the southeast, with the exception of Florida (where a lot of retirees from up north live). The 'yinz' map showed a high concentration in the western half of Pennsylvania, which is correct (according to Wikipedia and my friend who grew up in that area). But I was a bit curious about a second yinz concentration encompassing several counties located along the border of North Carolina & Virginia. I've never really heard the word yinz used in that area, so I was a bit skeptical. So I decided to dig a little deeper...

Any time smoothing is used, there is a possibility it will distort the true nature of the data. Therefore I decided to plot the unsmoothed yinz data, to see if it might shed some additional light on this odd NC/VA concentration. As I suspected, the raw data map showed that it was really only a couple of counties (Orange and Person) that had the high number of Twitter posts containing the word yinz. So in this particular case, the smoothing exaggerated the NC/VA yinz hotspot quite a bit, and it's probably better to use the unsmoothed data. (Which reinforces my suggestion to always plot your data in several different ways!)

wordmap_yinz_circle


And now for a fun example ... My friend Margie is a bit of a local legend. Her passion is to create clever signs to hold up during sporting events (especially ice hockey) - they are frequently shown on the jumbo screen, and sometimes even on television. She's earned the nickname Clever Sign Chick, which she wears proudly. She spent her early childhood in western Pennsylvania, and therefore she's familiar with their local words such as 'yinz'. So when the Pittsburgh team came down to play our NC team, she greeted them with the following sign (all in good fun, of course!) ... which is an example of a perfect combination of the slang words yinz (commonly used around Pittsburgh), and ain't (commonly used in NC).

yinz_sign

What special slang words are unique to your area? Feel free to share in the comments!

 

Post a Comment

Character to Numeric Conversion in SAS

character-to-numeric-conversion-in-sas_bookHow many of you have been given a SAS data set with variables such as Age, Height, and Weight and some or all of them were stored as character values instead of numeric?  Probably EVERYONE! Yes, we all know how to do the old "swap and drop" (rename and convert), but wouldn't it be nice to perform the conversion in one macro call? You can download the Char_to_Num macro (for free) from my author site, from the book Cody's Collection of Popular Programming Tasks, or from the listing right here in the blog. You call the macro with the name of the original SAS data set that contains one or more variables you want to convert, the name of the SAS data set for the converted variables, and a list of character variables that need converting. Right after the macro listing, I'll show you an example:

Here is a listing of the macro:

*Macro to convert selected character variables to numeric variables;
%macro char_to_num(In_dsn=,   /*Name of the input data set*/                                                                            
                   Out_dsn=,  /*Name of the output data set*/                                                                           
                   Var_list=  /*List of character variables that you                                                                    
                                want to convert from character to                                                                       
                                numeric, separated by spaces*/);                                                                        
   /*Check for null var list */                                                                                                          
   %if &var_list ne %then %do;                                                                                                           
   /*Count the number of variables in the list */                                                                                       
   %let n=%sysfunc(countw(&var_list));                                                                                                  
   data &Out_dsn;                                                                                                                       
      set &In_dsn(rename=(                                                                                                             
      %do i = 1 %to &n;                                                                                                                 
      /* break up list into variable names */                                                                                           
         %let Var = %scan(&Var_list,&i);                                                                                                
      /*Rename each variable name to C_ variable name */                                                                                
         &Var = C_&Var                                                                                                                  
      %end;                                                                                                                             
      ));                                                                                                                               
 
   %do i = 1 %to &n;                                                                                                                   
      %let Var = %scan(&Var_list,&i);                                                                                                   
      &Var = input(C_&Var,best12.);                                                                                                     
   %end;                                                                                                                               
   drop C_:;                                                                                                                           
   run;                                                                                                                                 
  %end;                                                                                                                                 
%mend char_to_num;

As an example, the code below creates a SAS data set (Contains_Chars) followed by a call to the macro:

data Contains_Chars;
   input Name $ Age $ Height $ Weight $;
datalines;
Ron 55 72 180
Jane 57 63 101
;
 
%Char_to_Num(In_Dsn=Contains_Chars, 
             Out_Dsn=Corrected,
             Var_List=Age Height Weight)

The new data set Corrected has the same variable names as the character variables in the Contains_Chars data set except they are now all numeric variables.   Here is a section from PROC CONTENTS:

Character to Numeric Conversion in SAS

I hope this macro will save you some time on your next project.

Post a Comment

Beer: Finding your favorite that you didn't know about!

Data analysis can be used for many things ... how about finding other beers you might like, so you don't keep drinking the same old brand every time? Hang on tight - I think we're about to make a beer run!

I recently read an interesting article on the Flowingdata website, where they graphically charted 100 beer styles. For each style, they drew a rectangle with the width representing the amount of alcohol by volume, and the height representing the bitterness (hoppiness).  They colored the rectangle to try to represent the average color of the beer, and grouped the graphs by family. As you mouse over each of their graphs, it gives you a description of that style, and lists several different brands of beer from that style. Here's a screen-capture of  the graphs for the family of beers in the Pilsner style, for example:

pilsner_original

I found their graphs very interesting, but I also noticed a few things I would have done differently, using SAS graphs. Let me walk you though my changes and enhancements, and see if you like them!

One thing that I found baffling was that they showed an overlay of all the beer style rectangles at the top of the Flowingdata article, but it was purely for artistic purposes. It had no axes or grid lines, and there was no way to tell which rectangle represented which style.

beer_styles_overlay

In my version, I used overlay graphs for their analytic power (rather than artistic power). I created an overlay graph for each style family, so you could see how consistent (or inconsistent) the beers from that family are. For example, here's my overlay graph, followed by the individual style graphs, for the Pilsner style family:

pilsner_sas

In the Flowingdata article, they omit the text & numeric labels along the axes of the individual style graphs, and just show the labels on a single graph at the top of the article. I found that I had to keep scrolling back up to the top to see what the axis values were, and then scrolling back down to the style graph I had been looking at (and hoping that I had correctly remembered the values). By comparison, in my version I fully labeled every graph - this makes them a little more cluttered, but a lot more usable.

The graphs were very small in the Flowingdata article, and therefore the data rectangles were sometimes just a visual 'speck' with more of the black border color than internal yellow/amber beer color. I made my graphs about twice as big, to allow you to see the data better. And on the topic of color - I decided to make all my polygons the same color, to make them easier to compare (I'm not sure that an average color for a particular beer style is very valuable to graph, and I wonder if the colors in the original graphs are actually representative of the beer colors?) Also, the lighter and darker rectangles in the Flowingdata graphs could distort the visual perception of their sizes.

In their article, there was no way to navigate through the style families. You had to scroll up/down, and read all the family names, to find the family you were interested in (and the difficulty was compounded, because the names were not in alphabetical order). In my version, I create a list of all the style families, and let you click the style name to jump directly to those graphs.

style_list

When you hover your mouse over my graphs, you see the description of that style and list of several different brands of beer that are that style (similar to the Flowingdata graphs) ... but you can also click my graphs to launch a Google search for that beer style. The Google search returns some really nice information, and also pictures of the beer (I think the pictures provide much more accurate colors than the colors used in the Flowingdata polygons, if you want to really know what the beer looks like). And for a finishing touch, I add a footnote at the bottom of my graph, giving credit to the data source, and a link to the actual spreadsheet containing the data.

And now, with all this data, how might you use it to find new/different beers, similar to the ones you like? I invite you to tell me - in the comments section!


And what would my blog posts be without some randomly-related pictures from of my friends?!? This time, pictures of beer! ... or should that be 'pitchers' of beer!?! LOL  (Thanks Beth, Paul, and Jason!)...

beer6 beer5 beer4

 

 

 

 

 

 

 

 

beer3

beer2 beer1

 

 

 

 

 

 

 

 

 

 

Post a Comment

SAS Jedi Christmas - SAS 9.4 M4 DS2 Do Loop Upgrade

This SAS Jedi is very excited about the SAS 9.4 M4 release, which brought many wonderful gifts just in time for Christmas. So in the interest of extending the Christmas spirit, I'm going to blog about some of my favorites!

I've long loved the SAS DO statement variant which allows iterating over a discrete list of values:

data test;
   call streaminit(12345);
   do Month='Jan','Feb','Mar';
      Revenue = round(rand('NORMAL',1000,100));
      output;
   end;
   format Revenue dollar8.;
run;


Until now, this has only been available in the traditional SAS DATA step. Neither DS2 nor SAS Macro had this feature. And every time I teach the DS2 class, I've had to say it wasn't available in DS2, but was on my wish list. Well, with the M4 release of SAS, I don't have to wish anymore! :-)

proc ds2;
title 'DS2 Results';
data;
   dcl char Month;
   dcl int Revenue having format dollar8.;
   method init();
      streaminit(12345);
      do Month='Jan','Feb','Mar';
         Revenue = round(rand('NORMAL',1000,100));
         output;
      end;
   end;
enddata;
run;
quit;

jedi20161228_ds2_data_program

So Merry Christmas from SAS! As usual, you can download the code for this episode from HERE.

And may the SAS be with you in the New Year!
Mark

Post a Comment