RATCLIFFE

Technical Services Limited

NOTE:

Issue 9. May 2002

Hints, tips, and experience for SAS(r) users

 


In this issue:

It's been a few months since the last issue of NOTE:. In those months we've been extremely busy satisfying interest in ASAP(tm). As part of our efforts with this innovative SAS productivity tool we have been establishing a network of resellers to provide local support throughout Europe, Middle East, and Africa. Our web site lists our resellers (see Product Focus for details). Existing ASAP customers should also find our occasional Product Focus articles of particular interest.

In addition to Product Focus, this issue contains our usual mixed-bag of hints, tips, and experience. Please continue to let us know what you like to see (and what you don't). And in addition, we have changed the style of the newsletter - the reds and greens have been replaced by plain and simple black, white, and grey. We hope you find it easier to read - please tell us what you think.

NOTE: is free. If you find it useful, please forward it to your friends, colleagues, and clients. Encourage them to take-out their own subscription by sending a plain text email to listmgr@ratcliffe.co.uk with a subject of "subscribe-note.colon" (without the quotes). Or just click here.

-Andrew
note.editor@ratcliffe.co.uk

.
 

Tools of the Trade - Log Filter

New in the RTSL web site's Tools section

In the Resources section of our web site we try to offer items of use to fellow SAS professionals. The Tools section includes a couple of utilities that we find useful. They are not polished, shrink-wrapped, commercial applications. They are simply rough-and-ready tools that we believe provide some useful functionality. 

A recent addition to the Tool section is our Log Filter. If you frequently need to check SAS logs (either in interactive SAS's log window, or in an external file) you will realise that there are a significant number of different messages that you need to scan for. And, that means it is not possible to issue one single find command to do that scan. Well, Log Filter will scan for many messages all at the same time, and it will return you a list of log lines that contain the sought-after messages. You can then double-click on any of those lines to have the log file positioned to allow you to view the context of the message.

We don't provide any warranty on any of our web-provided Tools, but we do welcome your comments. So, please try it and tell us what you think.

 

Return to top...

 

Sources of Information

Good places on the web

In issue 2 we covered Newsletters About SAS Software. There aren't many!

There are, however, many web sites with useful SAS-related information. Perhaps too many! It is difficult to split the good from the average. To help you sort the wheat from the chaff, we would suggest you pay close attention to the following three sources. Two of them are webrings. Webrings are a simple way of grouping similar sites together to make it quick and easy to navigate between them

The SAS Software Webring has its index page at d.webring.com/webring?ring=sassoft;index. This webring joins web sites which have SAS as their primary topic.

The SAS FAQs, Hints and Tips Webring collects web sites containing FAQs, hints or tips about the use of SAS. It has its index page at d.webring.com/webring?ring=sasfaq;index

Finally, Links2Go offer a SAS page at www.links2go.com/topic/Sas. The Links2Go directory is compiled from SAS-related sites scoring the highest number of hits.

If you know of any other good indexes of web sites, please let us know.

 

Return to top...

 

Product Focus

News and tips

In this article, we present a few hints and tips on the usage of ASAP, complementSoft's innovative productivity tool for SAS programmers. Amongst many other features, ASAP automatically produces diagrams of your SAS code. More information on ASAP can be found on our web site at www.ratcliffe.co.uk/prd_asap.htm.

.

Visualise your log too

As an ASAP user you will be well aware of ASAP's ability to produce diagrams of your SAS code, but did you know it can visualise your log too? Using this feature of ASAP you can produce diagrams that show what your macros are doing (make sure OPTIONS MPRINT is switched on) and what is happening in your included code (make sure OPTIONS SOURCE2 is switched on). To visualise the log, open your code in the Editor, click the Log tab, then click the Visualiser button. The diagram of the log will show the flow of the data and code that was generated by the macro and/or included files.

If you have a log file with no associated ".sas" file, that's not a problem. Just open the log file in the ASAP editor, click the Log tab, and then click the Visualise button.

.

Resellers and SeUGI

Our current network of resellers for ASAP extends across Europe, via the UK, France, Netherlands, Germany, and Italy. If you would like to know more about ASAP and its ability to automatically produce data flow diagrams of your SAS code (and logs), contact one of our resellers, or come and see us on the PW Consulting stand at SeUGI (Paris, 11-13 June).

 

Return to top...

 

Watch Your Case

Beware mixed-case variable names

A client of ours had a sticky problem whereby a program involving a complex set of macros ran fine in V8 but failed in V6. We were able to help them track it down to a line of code that was using a variable name in a macro string compare:

%if &varname eq lo_hgb %then

Prior to the failing statement, a data set had been transposed, and the resulting variable names had been loaded into a macro variable array. An element of the array was being used in the varname macro variable. Here is the PROC TRANSPOSE statement:

proc transpose data=lows prefix=lo_ out=xlows;

The string comparison was "true" in V8, but "false" in V6. Reason? V8's use of mixed-case variable names. In particular, PROC TRANSPOSE's PREFIX parameter respects the case coded by the user. So, in V8 the variables in the xlows data set had names prefixed with lower-case "lo_", but in V6 the variable names were all upper-case and the comparison failed.

A number of solutions were open to the client, but the one chosen was to use OPTIONS VALIDVARNAME=V6 and to change the comparison code to upper-case.

Some example code that demonstrates this issue can be downloaded from here.

 

Return to top...

 

Deleting Macro Variables

How to delete one or more of your macro variables

The mention of macro variables in the previous article prompted discussion in the office regarding how to tidy-up one's macro variable environment. SAS's FAQ #1780 describes how to take care of your global macro variables.

 

Return to top...

 

Where Is CITIDAY?

More information on issue #8

In the Linking Your Tables article in issue 8, we made reference to a data set named sashelp.citiday. BR kindly pointed out to us that this data set is only present on your system if you have installed SAS/ETS. We were unaware of this at the time and are grateful for BR's information.

Remember that you can install the SAS/ETS code and sample from the CD without being licensed for the product. So, if you are desperate to get hold of CITIDAY, you can!

 

Return to top...

 

V8 Editor Tips

Indentation

Back in the days when the Program Editor was the cutting edge of SAS program editing, we used to use '>2' line commands to indent a line by two characters. And we would use '>>2' to mark the starting and ending lines of a block that we would like to indent. But V8's enhanced editor does not permit line commands, so how do we achieve the same results?

The answer is to select the line or block of text to be indented and then hit the Tab key. This somewhat counter-intuitive action will indent your program code. To control the number of characters used for each level of indentation, visit the Tools->Options->EnhancedEditor menu; on the General tab you will find the Tab Size option. Note that the EnhancedEditor sub-menu is only available when an enhanced editor window has the keyboard focus, i.e. you need to click on an enhanced editor window before trying to find the Tools->Options->EnhancedEditor sub-menu.

.

New and old colours

A number of our clients like to use .old and .new as qualifiers for their SAS programs (alongside .sas). They are always pleased when we are able to tell them how to get the enhanced editor to provide colourisation for these non-standard qualifiers. Just go to Tools->Options->EnhancedEditor and click the FileExtensions button. The resulting dialog allows you to define file extensions that are recognised by the editor as SAS code.

.

Move quickly

And, did you know that ctrl-G in the V8 enhanced editor allows you to go to a specified line number?

 

Return to top...

 

SAS(r) With Style

Sound SCL structure makes sense

If you are an SCL programmer, do you favour a small number of large SCL entries, or a large number of small entries? Many people aim for the compromise middle-ground, but it is very easy to end up with large SCL entries. Those large entries can be the result of a number of things, including the gradual growth of individual entries over time as new functionality is added.

Are large SCL entries (or large base SAS programs - the issue is the same) a bad thing? Whilst I do prefer my teams' code to be kept in small to medium size entries, the key element to me is not the size but the structure. A large SCL entry can be well structured and manageable; a small/medium sized entry can be badly structured and very difficult to understand, maintain, and debug. If your large code is well structured, you will be able to easily break it out into smaller SCL entries if you wish.

So, what is good structure? Good structure consists of small/medium size blocks of code that have a clear purpose and set of responsibilities together with clear interfaces and boundaries. Clear purpose and responsibilities comes from good planning and design; clear interfaces and boundaries come from using a modular/object-oriented approach favouring the use of methods over link statements and goto statements.

James Ochiai-Brown and I wrote of these things in more detail in our 1997 paper entitled Flexible Financial Reporting, presented at SeUGI that same year. Giving your modules/objects a clear purpose and set of responsibilities gives them a sense of character and you find that your modules/objects naturally begin to work in synergistic ways. As new functionality is required, it will be obvious which modules/objects should take on that functionality if each of them has clear purpose.

By using methods you gain the benefits of locally scoped variables, i.e. variables that only exist within the specific method. Hence, the only way to get values in or out of the method is via the parameter list. The parameter list is the best interface on the module boundary.

Passing values between methods via globally scoped objects such the environment lists is not advisable because one loses clarity over who is responsible for creating the values and/or who is responsible for maintaining them. Equally, using goto and link statements is inadvisable because they do not support clear parameter lists and thus they do not provide clear boundaries between units of code.

.

Refactor your code

It is inevitable that your modules/objects will grow larger as time progresses and more features are added. Whenever you add code, consider whether "now" is the time to split your module/object into a set of smaller modules/objects with more tightly defined and specific purposes and sets of responsibilities. This process is called refactoring and is a natural result of application development and growth.

Refactoring (and the inevitability of it) is a significant feature of eXtreme Programming (XP). One of the prime exponents of XP is Martin Fowler, and his book Refactoring: Improving the Design of Existing Code is a classic. For more on the subject, and for details of the book, visit Martin's web site at www.refactoring.com.

 

Return to top...

Advertisement

 

Diary

 

This diary provides a guide to some of the world-wide events we might like to attend. Those marked with an asterisk are those that we will be attending. If you plan to go to any of the listed events, please let us know - we'd be very grateful for any comments after the event. And it would be nice to meet if we are going too.


World-wide events


May 2002
26th - 29th, XP2002 (eXtreme Programming), Sardinia, Italy Premier European conference on eXtreme Programming and flexible processes in software engineering.

June 2002
11th-13th, SeUGI (SAS Users Group International in Europe), Paris, France. Premier SAS conference in Europe.*

November 2002
4th - 8th, OOPSLA, Seattle, USA. Premier object technology conference world-wide.

.March 2003
30th - 2nd April, SUGI (SAS User Group International), Seattle, USA. Premier SAS conference world-wide.*

 

Return to top...

 

Miscellany - Joining, leaving, back-issues, and legal bits

 

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/note_colon.

Please send comments to note.editor@ratcliffe.co.uk.

NOTE: (c) 2002 Ratcliffe Technical Services Limited. All rights reserved.
5 Willow Close, Bexley, Kent, GB-DA5 1QY, England.

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:.

NOTE: is a production solely of RTSL and has no affiliation with any other organisation.

This edition of NOTE: was sent free to 603 subscribers worldwide.

This is a valid HTML 4.01 Transitional document

 

Return to top...