Friday 30 September 2011

NOTE: Base SAS Tip Sheets

I think I may have mentioned these in passing before, but they're certainly worth a repeat reference. The right-hand margin of the Base SAS Focus Area on the SAS Support web site offers a number of free tip sheets for download. I've been using the PERL Regular expressions sheet a lot recently. The Hash Object sheet is a popular handout when I'm teaching PRG3 - Advanced techniques and Efficiencies.

Why not earn yourself some Brownie points within your team by printing-off some of these sheets, laminating them, and handing them around the team?

Wednesday 14 September 2011

Predictive Modelling Competition Ends Soon

Back in August I mentioned that one of my clients was running a predictive modelling competition with a $10,000 prize fund. The competition closes on Friday September 30th, just a couple of weeks away, so if you intend to enter but haven't done so yet, you need to get your skates on!

I'm no predictive modeller, so I entered the competition out of sheer curiosity. At the time that I made my entry I was ranked 90th, today I'm 151st. I guess that none of the prize fund will be heading in my direction!

Tuesday 13 September 2011

NOTE: Substringing Without Notes

The SUBSTR function is a much-used function but can be frustrating when it issues an abrupt NOTE to the log when the string isn't long enough to produce a result.

If the design of your code means that you're happy to allow a null result from your sub-string function, consider using SUBSTRN. This function provides the same essential functionality as SUBSTR but will not issue a NOTE message if it returns a null result. The two DATA steps below show the contrast in results:

15 data _null_;
16   MyString = 'Shorty';
17   a = substr(MyString,1,10);
18   b = substr(MyString,15,10);
19   put a= b= ;
20 run;

NOTE: Invalid third argument to function SUBSTR at line 17 column 8.
NOTE: Invalid second argument to function SUBSTR at line 18 column 7.
a=Shorty b=
MyString=Shorty a=Shorty b= _ERROR_=1 _N_=1
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

21
22 data _null_;
23   MyString = 'Shorty';
24   an = substrN(MyString,1,10);
25   bn = substrN(MyString,15,10);
26   put an= bn=;
27 run;

an=Shorty bn=


Notice in particular how the attempt to assign a value to B where the starting position is beyond the length of the string produces _ERROR_ set to 1.

In the right situation, SUBSTRN can be very handy.

Tuesday 6 September 2011

NOTE: Charity Drive Ends Successfully

Congratulations to David Shannon and his brother Paul for completing their 1,200+ mile journey from Land's End to John O'Groats, by B-roads, in their 1974 MGB Roadster.

Even bigger congratulations to them for raising over £2,100 pounds for their chosen charity, exceeding their £1,200 target by quite some margin. It's not too late to contribute if you would like to offer them congratulations in a material way.

The constant stream of tweets has told us that their car was totally reliable. David and Paul sound very tired, but satisfied with the range of teas and cakes they've sampled along the way!

NOTE: Better Access to SYSTASK and OS Commands in SAS 9.3

Back in June I extolled the virtues of the SYSTASK statement, but was frustrated by my inability to use it in certain circumstances. So I was very pleased to see Chris Hemedinger writing in his blog recently that the default ability to use SYSTASK (and its equivalents) has been eased in appropriate circumstances such as when using EG and SAS on the same PC.

Thanks for the good news, Chris.

NOTE: Changing the Default Length for Numeric Values

Choosing appropriate lengths for the variables in your SAS data sets can have a significant effect on the size of your SAS datasets and hence a) the disk space they consume, and b) the speed with which they are written to and read from disk.

The default length for numeric values is 8 bytes; this is the maximum length too. For non-integer values you shorten the length at your peril, but if you're using integer values then you can consider shortening the length(s) and saving disk space.

The LENGTH statement's DEFAULT parameter allows you to specify a default length for newly-created numeric values. This can be useful if you are creating a number of date variables and/or binary flags.

SAS paper TS-654 provides plenty of information on numeric precisaion. Crucially, the table at the bottom of the second page shows the range of integer values you can safely store in variables of reduced length.

NOTE: SAS Available on iPad! Free!!

Have you seen the SAS News app (available from the iTunes App Store)? It looks to be a neat alternative to following SAS blogs and press channels through an RSS reader. In SAS's own words: "Follow and share the latest news, social feeds, product information, customer stories and more from SAS, the leader in business analytics software and services."

Okay, I confess, I was just aiming for an eye-catching headline! I'm not an Apple customer, so I shan't be downloading it soon.

Perhaps of more interest, SAS have a second product in the iTunes App Store. If you have an iPad, iPhone or iTouch, take a look at SAS Flash Cards. This is an education/business product that is not directly related to SAS software. The free app allows you to create your own decks of flash cards for use in teaching and/or presentation situations. It's worth a look if you have an iOS product to run it on. If you gave it a try, let me know what you think...