|
RATCLIFFE Technical Services Limited |
NOTE: |
|
Issue 3. April 2001 |
Hints, tips, and experience for SAS(r) users |
|
|
This is the third issue of NOTE: and I feel I'm getting into the rhythm of producing this monthly eNewsletter. I know from the emails you've sent me that the majority of you are very keen on this new source of information about SAS software. Thank you too for the suggestions for topics. NOTE: will focus on application development (in its widest sense) so don't expect too many articles about statistics or capacity planning; but many aspects of SAS software usage run across all areas of interest, so most issues should have something of interest for most people. This issue and future issues will have a wide mixture of lower-level language technicalities combined with higher level articles about SAS solutions and development techniques. Please keep your suggestions coming. And don't forget to tell your friends, colleagues, and clients about how to subscribe to NOTE: - it's free, just send an email to listmgr@ratcliffe.co.uk and type "subscribe-note.colon" as the subject (without the quotes). NOTE: is published on the first Tuesday of each month. The next issue will be published soon after I return from SUGI. I'll be publishing highlights of the annual SAS jamboree. If you're going to SUGI and you see me around, please say "hi". -Andrew |
|
It's only taken six months for the seller to complete the Nominet paperwork correctly! |
After a very long wait, we finally have a place of our own on the Internet. We have just taken receipt of the ratcliffe.co.uk domain name. Apart from the fact that we've built a brand new web site at the new address - www.ratcliffe.co.uk - what else does this mean for you? Well, not much really except that subscription (and removal) messages should now be sent to our new email address: listmgr@ratcliffe.co.uk. We'll maintain the old domain for some time to come, but I'd encourage you to use the new address. If you ever took a look at our old web site you will have seen that it was an eclectic mixture of items of interest. I urge you to take a look at our new web site and get a far clearer picture of what Ratcliffe Technical Services does, plus you can download and read some of the papers that I have produced, and we have a free download area for SAS-related tools that we have produced. |
|
Featuring the SCAN and REVERSE functions |
Just recently I had a task that involved parsing a UNIX cron file. The techniques and functions I used to achieve this bear some scrutiny. You don't need to have any interest in UNIX or cron to appreciate the details of this. I needed to read and understand (parse) lines from a cron table. The lines' syntax is as follows: mm hh dd mm w command Where mm, hh, dd, and mm represent the time and date that the command should automatically be executed. The "w" part indicates the day of the week that the command should be executed (0-6 with 0=Sunday). So if you want a command issued at 10:30 on the 6th of each month, you'd code: 30 10 6 * * mycmd Notice how asterisk (*) is used to indicate no preference, i.e. all values are acceptable. My task was to look for all occurrences of a specific type of invocation of SAS. The syntax of the command to launch SAS was as follows: /path to app/mySasScript parm1 parm2 parm3 In particular, parm3 would be "XXnnnnnn" where nnnnnn is a six-digit integer numeric value. So, how could I scan an SCL list such as that shown below, pick-out only those commands that met my syntax above, and place the three parameters into items in the list? To pick-out my commands, I need to be sure that the script name is "mySasScript" and the third parameter must be of the "XXnnnnnn" format. And to do that, I must be able to pull-out the command and the third parameter from the cron line. I chose to use the REVERSE function together with the SCAN function. REVERSE's purpose is clear, but the SCAN function is sadly under-used. SCAN returns a word from a string. A word is defined as a string of characters separated from others in the string by word-separator characters. SCAN has good defaults but also allows you to specify word-separator characters for your particular purpose. To check that parm3 meets my format, I must first extract it from my cron line. Well, it's the last word in the string (where words are separated by blanks). SCAN allows you to specify which word you want, i.e. the Nth word, but isn't flexible enough to allow you to say you want the last word. But if we reverse the string, parm3 will become the first word, so that's what I did: reverseCronLine = reverse(cronLine); reverseParm3 = scan(reverseCronLine,1,' '); parm3 = reverse(reverseParm3); So now I could check its format. valid = 1;
if length(parm3) ne 8 then valid=0;
if valid then do; /* Now check XX */ if parm3 ne: 'XX' then valid=0; end; /* Now check XX */
if valid then do; /* Now check nnnnnn */ testResult = compress(substr(parm3,3) ,'0123456789' ); /* If numeric we will have removed all chars by compressing-out all digits */ if testResult ne '' then valid=0; end; /* Now check nnnnnn */ Needless to say, I found the name of the script as the fourth word in the reverse cron line. This required the use of space and slash as word-separators (my syntax was such that the parameters could not include space or slash): reverseScriptName = scan(reverseCronLine,4,' /'); if reverseScriptName ne reverse('MySasScript') then valid=0; I won't bore you with the remaining details of the task, but I hope you will agree that the REVERSE and SCAN functions made an otherwise tricky task turn out to be relatively simple. I was using V6.12 of SAS when doing this. If I had V8 available to me the task would have been somewhat more straightforward because I could have coded parm3 = scan(cronLine,-1,' ') in order to get the last word. The negative value for the word-number indicates that the words are counted from the end of the string. And I could have got parm1 with parm1 = scan(cronLine,-3,' /'). So, with V8 I wouldn't have needed to use REVERSE, and SCAN becomes even more usable. |
|
|
This section of NOTE: covers coding standards. It is also a good source of discussion! The last two issues have generated a great deal of correspondence. Please keep the comments coming, but as I've said before, the most important aspect of coding standards is to have them and use them - it is not important that your coding standards match those of RTSL. |
|
|
rc = insertc(lParm ,getitemc(lInput, 2) ,- 1 ,'DEMONSTRATION PARAMETER' ); if rc ne lParm then put 'ERROR: The INSERT function failed'; I recognise that minimising the use of nested functions necessarily increases the number of intermediate variables. However, a compromise must be reached between run-time efficiency and efficiency of maintenance programmers. My preference is for more intermediate variables and less nesting. |
|
Will the apps developers' friend (SCL) be superseded by Java? |
As SUGI approaches, my mind turns to V9 and the changes that V9 and subsequent releases may encompass. We know it'll incorporate multi-tasking, but what else? Is it possible that SAS Component Language (SCL) might be superseded by Java? To understand why this might make sense I think you need to look at application development using the three-tier model: presentation layer, functionality layer (business logic), and data layer. Where do SAS's strengths lie? Answer: in tiers 2 and 3 (functionality and data respectively). SAS/AF frames are very nice, but they don't provide anything over-and-above the myriad of other interactive development environments (IDEs) that are widely available (such as Microsoft Visual Basic, C++, or Java). I'm talking about development environments here, not just languages. Thus, the major development environments for these languages all provide screen building tools similar in functionality to the frame editor in SAS. I'm not suggesting that SAS's frames are a weakness, I'm simply saying that SAS's strengths are in the 2nd and 3rd tiers. If SAS are able to provide the access to SAS features as well as SCL currently does, then why not encourage developers to move from SCL to, say, Java? SAS can save money because they won't need to develop and maintain their own screen development environment; customers save money because programmers in commodity languages such as Java are cheaper than SCL programmers. I'm quite sure that SCL (and frames) would be supported for a long time to come, but SAS might choose not to add additional functionality and to focus their efforts on Java support instead. The key to it all is packaging-up SAS functionality to make it accessible to commodity languages. And if that can be done for tier 1, the same could apply to tiers 2 and 3 too. Thus, SCL could be wholly superseded by, say, Java. This puts aside any performance issues that are introduced by the interface between the chosen language and SAS. These performance issues may mean that some half-way-house solution is offered whereby the SAS system has inbuilt support for a language such as Java. AppDev Studio is a good example of tier 1 Java support for a thin-client. I'm expecting to see SAS take the same approach with thick-client and back-end server development. By combining the unique features of SAS (including the Base SAS language structure of DATA steps and PROCs) with a generally supported language (such as Java), SAS and their customers get the best of both worlds. Frames are great and give you easy access to SAS functionality, for instance you can drag a data set model and drop it on a list box and instantly see the variables or observations of the data set; but AppDev Studio has shown how that can be done in a Java IDE with added SAS features. And that's my point, if it can be done in a thin-client environment, why not do the same for thick-clients and back-end servers. I'm hoping to return from SUGI at the end of this month with a clear understanding of the future path for SCL and for SAS/AF in general. Rest assured that there will be more information in issue #4 of NOTE:. I will have a report on SUGI in general, and SAS/AF in particular. |
|
Features of new versions, and support for old versions |
For information on V8.2 of SAS software, take a look at www.sas.com/newversion. There is information on enhancements and new features (as an A-Z list, by product, and by platform). The introduction of new releases of SAS software inevitably raises questions about support for older versions. SAS recently released the following statement in Europe regarding support for V6.09E and V6.12. Support in other regions is likely to be the same or similar, but check with your local SAS office to be sure. Support to December 31, 2001:
Note that this is the same level of support offered for current (Version 8) releases of SAS. From January 1, 2002 through December 31, 2002, we will provide the following support for releases 6.09E and 6.12 of SAS:
Beginning January 1, 2003, and extending indefinitely, we will provide the following support for releases 6.09E and 6.12 of SAS:
So, the older releases are full supported through 2001. In 2002, the provision of zaps and patches changes from "will be provided" to "may be provided at our discretion". And from 2003, no new zaps or patches will be forthcoming, and problem alerts won't be distributed. |
|
Advertisement |
|
|
Useful SAS-related services and products |
|
|
|
If I were not constrained by the need to earn money by working(!), this diary provides a guide to some of the world-wide events I might like to attend. Those marked with an asterisk are those that I will be attending. If you plan to go to any of the listed events, please let me know - I'd be very grateful for any comments after the event. And it would be nice to meet if I am going too. |
|
|
22nd - 25th, SUGI (SAS User Group International), California, USA. Premier SAS conference world-wide.* May 29th - 1st June, SEUGI (SAS European Users Group International), Florence, Italy. Premier SAS conference in Europe.* July August 20th, SUCHI (SAS Users Chicago), Chicago, USA.* September 25th - 26th, VIEWS, London, England. Premier SAS conference in UK. Dates are provisional.* October April 2002 |
|
|
You can subscribe and unsubscribe by visiting our web site at www.ratcliffe.co.uk. Or, to subscribe just click here and hit the Send button in your email client; and to unsubscribe, just click here and hit the Send button in your email client. Please do not include a message in the body of the email, it will not be seen by a human! Back issues are available on our web site at www.ratcliffe.co.uk. Please send comments to note.editor@ratcliffe.co.uk. NOTE:
(c) 2001 Ratcliffe Technical Services Limited. All
rights reserved. Republication by permission only. You may forward copies only if no fee is involved. Please encourage the recipients of the forwarded copy to subscribe and get their own free copy of NOTE:. Andrew Ratcliffe is a registered partner of SAS UK. NOTE: is a production solely of RTSL and has no affiliation with SAS UK. Andrew is chairman of VIEWS (the UK's independent SAS user group). NOTE: is a production solely of RTSL and has no affiliation with VIEWS. This edition of NOTE: was sent free to 327 subscribers worldwide. This is a valid HTML 4.01 Transitional document |