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; |
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
6 Comments
What did I do wrong? I got this error, ERROR: Compilation error
127 proc ds2;
128 title 'DS2 Results';
129 data;
130 dcl char Month;
131 dcl int Revenue having format dollar8.;
132 method init();
133 streaminit(12345);
134 do Month='Jan','Feb','Mar';
135 Revenue = round(rand('NORMAL',1000,100));
136 output;
137 end;
138 end;
139 enddata;
140 run;
ERROR: Compilation error.
ERROR: Parse error. Expecting TO on source line 134: streaminit(12345); do Month='Jan' ==>,.
141 quit;
NOTE: PROCEDURE DS2 used (Total process time):
real time 0.04 seconds
cpu time 0.04 seconds
Mike,
Are you using the latest (November 2016) release of SAS (SAS 9.4 M4)? This blog is about new features in the new release, so you'll need the latest release to make this work. If you don't already have the latest version of SAS, that's OK - the SAS University Edition is free to download, and is always up to date! You can get it from http://go.sas.com/free_sas.
May the SAS be with you!
Mark
Thanks Mark and Happy new year! Great tip. Always leaning new things from you.
Annie
My pleasure, Annie :-) Wishing you and your family a joyful and prosperous New Year, too!
Mark
Very cool!
One of my personal favorites in M4 is the accessibility option for ODS HTML5 and PDF - such a HUGE timesaver for all of us submitting reports and files to government agencies!
Thanks for sharing.
I was especially excited about this one because it was an answer to a request by several customers and me, too. However, the ODS features are also amazing - stand by for more blogging :-)
Mark