RATCLIFFE

Technical Services Limited

www.NoteColon.info

NOTE:

Issue 12. August 2003

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

 Subscribe and/or view our archive of back issues at NoteColon.info


In this issue:

Welcome to issue 12 of our newsletter for SAS practitioners. Most issues cover a mixture of coding, architecture, design, processes, and project management (reflecting the strengths of RTSL) but this issue focuses on coding tips - with good reason...

New sources of information are always welcomed by NOTE:, and none are more welcome than a new (free) daily hints & tips newsletter by email from the highly respected Phil Mason. So welcome in fact that we've chosen to dedicate this entire issue to highlight Phil's new newsletter. There's information on how to subscribe, plus we've included (with Phil's permission) a small selection of our favourite recent articles.

I hope you agree that Phil's newsletter is a valuable addition to the existing published knowledge on SAS software. Support Phil's efforts by encouraging your colleagues and clients to subscribe to the Woodstreet Newsletter.

-Andrew Ratcliffe
note.editor@ratcliffe.co.uk


 

The Woodstreet Newsletter

How to subscribe to Phil's newsletter

Phil's free newsletter is a daily email delivered to an email address of your choice as either HTML or as plain text. To subscribe, just send an email to tips@woodstreet.org.uk with a subject line of "subscribe sastips-html" or "subscribe sastips-text" (without the quotes).

Phil is Managing Director of Wood Street Consultants Limited and there's an archive of previous tips accessible from the Wood Street Consultants' web site at www.woodstreet.org.uk.

For those who don't know of Phil, he's a widely respected author of books and papers on SAS topics and can often be seen speaking at SAS user group meetings worldwide. Phil was Chairman and a founding member of VIEWS (the UK's SAS user group).

The newsletter tips frequently reference SAS documentation that is available on the Internet. You can sign-up for SAS's free service here. It offers OnlineDoc for both V8 and V9.

 

Return to top...

 

Tip 15 - Counting Words

A new function in V9

Rather than using a more convoluted technique for counting the number of occurrences of a word in a character string, in SAS 9 we can now use the COUNT function. It will simply count the number of sub-strings that occur in a string, optionally ignoring the case (as in my example).

Documentation on the count function can be found at http://v9doc.sas.com/cgi-bin/sasdoc/cgigdoc?file=../lrdict.hlp/a002260230.htm  [Information on how to obtain a userid/password for this free resource is in The Woodstreet Newsletter above]

SAS Log

15   data _null_ ;
16     sentence='This is ONE way of using one in One sentence' ;
17     num=count(sentence,'one','i') ;
18     put num= ;
19   run ;

num=
3
NOTE: DATA statement used (Total process time):
     
real time           0.00 seconds
      
cpu time            0.00 seconds

Example tested under SAS 9.0, Windows 2000    

 

Return to top...

 

Tip 23 - Putting a Number Into a Macro Variable (a Better Way)

Avoid those nasty messages in the log whilst also using fewer functions

In SAS 9 there is a new function called SYMPUTX which creates a macro variable from a numeric variable without writing a note to the log, and trims leading and trailing blanks. It will use a field up to 32 characters wide and you can optionally tell it which symbol table to put the macro variable into.

The example below show how SAS does an automatic type conversion and uses BEST12.2 to convert a numeric to character in line 44. The following line shows how we can explicitly do the conversion and trim the result. The next line shows how to use SYMPUTX to simplify the process.

See the following for more information - http://v9doc.sas.com/cgi-bin/sasdoc/cgihilt?file=/help/lrdict.hlp/a002295697.htm&query=symputx#~1 [Information on how to obtain a userid/password for this free resource is in The Woodstreet Newsletter above]

SAS Log

42   data test ;
43     my_val=12345 ;
44     call symput('value0',my_val) ; * auto conversion done ;
45     call symput('value1',trim(left(put(my_val,8.)))) ; * v8 ;
46     call symputx('value2',my_val) ; * SAS 9 ;
47   run ;

NOTE: Numeric values have been converted to character values at the places given by:
     
(Line):(Column).
     
44:24
NOTE: The data set WORK.TEST has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
     
real time           0.01 seconds
     
cpu time            0.01 seconds



48   %put =->&value0<-==->&value1<-==->&value2<-=;
=->       12345<-==->12345<-==->12345<-=

Example tested under SAS 9.0, Windows 2000                               

 

Return to top...

 

Tip 46 - Find in Enhanced Editor

Use regular expressions and be more expressive

The enhanced editor in SAS 8 has been improved in various ways over the old Program Editor. One improvement appears in the find window, which can be accessed by pressing Ctrl-F or using the pull down menu (Edit-Find).

There is now the opportunity to tell Find to look in: all the text, just the code or just the comments.

There is also the chance to specify regular expression searches, which allow pattern matching. If you are unfamiliar with this you can click on the right-facing triangle next to the Find text box. This has descriptions of things that can be specified in an expression. By selecting one of these the code will be entered in the Find text box, and can be customised.

This all works for Replace as well (Ctrl-H).

Some examples of regular expressions in a FIND TEXT box

Regular expression

Explanation

[sme]date

Match “sdate”, “mdate” or “edate

^data

Match “data” when at the start of a line

var_[abc123]

Match “var_a”, “var_b”, “var_c”, “var_1”, “var_2” or “var_3”

_*name

Match 0 or more “*” characters, followed by “name” – so it would match “_name”, “name”, “_____name”, etc.

proc \w+

Match “proc ” followed by 1 or more word characters – so it would match “proc print”, “proc datasets”, etc. – in fact “proc anything”

data\b+\w+

Match “data” followed by 1 or more write space characters and then 1 or more word characters – so it would match “data anything

[Don't forget to tick the "Regular expression search" box if you enter an expression manually]

More information on regular expressions can be found at http://support.sas.com/rnd/base/topics/datastep/perl_regexp/regexp.motivation.html though not all are supported by the Find dialog box.

Example tested under SAS 8.2, Windows 2000                     

 

Return to top...

 

Product Focus

Automatic diagramming of SAS code with ASAP

In June of this year, complementSoft released Version 4 of ASAP, the innovative code visualisation tool. To its ever expanding customer-base, ASAP provides the ability to automatically create data flow diagrams of SAS code. And in addition, its built-in FTP and Telnet clients allow its users to access SAS code on remote servers, and to execute the code on those remote servers too. ASAP's major features are rounded-out with its syntax-sensitive code editor.

ASAP is a pure Java application. With Version 4, ASAP has been upgraded to the latest Java Virtual Machine to enable tighter integration with Version 9 of SAS. Enhancements to directly benefit customers include:

  • Performance enhancements to permit bigger programs to be diagrammed even quicker

  • Windows document application association in the ASAP Document Manager means that clicking on a non-SAS file will launch the associated application, e.g. double-clicking on an MS-Excel file will result in it being opened in MS-Excel

  • Support for secure FTP (SFTP)

  • Ability to export the data flow to a flat file (for handling as metadata)

  • The Database Manager allows the user to view tables in ODBC data sources. It has been enhanced so that it now supports all ODBC data sources, including Sybase, Informix, Redbrick, Excel, and SAS data sets

ASAP is used across the widest variety of industries but most notably in pharmaceuticals where SAS code is included as part of the submissions to the drug regulation authorities. ASAP's automatic diagramming is used by the leading drug administration agencies, so if the pharmaceutical companies wish to see their SAS code in the same way as the regulatory authorities, they need ASAP!

RTSL is the international distributor for complementSoft products (including ASAP).

 

Practical business intelligence from Futrix

In May of this year, Futrix Software Limited announced the release of Version 4 (popular version number!), the latest version of Futrix – the SAS®-based Enterprise Business Intelligence Suite. This new version incorporates many new features that have been requested by clients, and updated technology delivers enhanced performance.

Futrix complements any SAS business intelligence implementation, providing advanced and simple reporting and analytical capabilities to users over the web, or using full client installations. It is quick to implement, easy to use and provides almost immediate return on investment. 

In addition to the existing suite of business decision making and reporting tools, Futrix Version 4 offers a wide range of new analytical capabilities that now enable telecoms companies to investigate churn patterns more closely, health care organisations to manage client behaviour better, financial services organisations to fine tune their investment models and for any organisation better to understand the drivers that impact their businesses.

Some of the additional business benefits to be gained by migrating to Futrix Version 4 include:

  • Futrix Web Version 4 now incorporates almost the complete functionality of the Futrix full client, enabling web users to exploit the broad range of analytical and reporting capabilities.

  • The introduction of row-level security broadens the capacity to distribute Futrix reports to a broader audience, while maintaining corporate access rights.

  • Non-English speaking customers will now be able to use Futrix in the language of their choice thanks to the introduction of multi-language support.

  • In addition to providing users with powerful new tools to enhance their decision making and understanding of their businesses, the engine that drives Futrix has been substantially upgraded.  

  • New administrative features have been added, making the management of the Futrix environment even simpler than before. 

  • Pre-calculated stored cache for very fast reporting

  • More than 150 documented enhancements since the previous release of Futrix (3.1), and even more minor enhancements

Visit www.futrix.com to download the latest demonstration version of Futrix.

RTSL is a value-added consultancy for sales and implementations of Futrix.

 

Return to top...

 

Tools of the Trade - ZipCoder

Another useful tool from Qualex

Qualex Consulting Services, Inc. has just released an updated version of their SAS Tool, "ZipCoder."

ZipCoder is a SAS program which displays all U.S. zip codes, cities, area codes, plus basic 2000 and 1990 census data for counties and states. Current as of June 2003, ZipCoder includes over 42,000 zip codes and has powerful searching capability. Using 2000 and 1990 US census data, basic county and state demographic data are provided including population, average household income, and estimated house values and household income.

With ZipCoder you can create graphs to compare demographic data between two states or to display high/low state comparisons. ZipCoder also allows you to easily copy graphs to other Windows applications. You can also query county and state census information. All tables and search results can be saved to a SAS data set or exported to HTML, RTF, or PDF.

ZipCoder automatically provides the mileage distance between selected two points. You can even view maps based on zip code, city or state using MapQuest (Internet connection required).

Context-sensitive help is included. This new version of ZipCoder is for SAS Version 8 only. It includes many new and updated features over the older version for SAS 6.12 which is still available. ZipCoder is free for personal and internal business use only.

To download ZipCoder, go to www.qlx.com/zipcoder

Qualex offers a wide assortment of SAS Tools available for download from www.qlx.com/tools.htm.

 

Return to top...

 

SAS(r) With Style

Make your code manageable and maintainable

The style guru is on holiday but will return in the next issue of NOTE:.

 

Return to top...

Advertisement

 

Diary

 

This diary provides a guide to some of the key world-wide events that we judge to be of interest to SAS professionals. If you visit any of the listed events, please send us an email and let us know what you thought of it.


World-wide events


May 2004
9th - 12th, SUGI (SAS User Group International), Montréal, Canada. Premier SAS conference world-wide.
19th - 21st, VIEWS (UK SAS user group), London, England. Premier technically-focused SAS conference in Europe
23rd - 26th, PharmaSUG (Pharmaceutical SAS User Group), San Diego, California, USA.

June 2004
? - ?, SeUGI (SAS Users Group International in Europe), ?, ?. Premier business-focused SAS conference in Europe. [details unknown]
6th - 10th, XP 2004 (eXtreme Programming), Garmisch-Partenkirchen, Germany. Premier European conference on eXtreme Programming and Agile processes in software engineering.
23rd - 26th, Agile Development Conference, Salt Lake City, Utah, USA.

 

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 from the archive at www.NoteColon.info.

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

NOTE: (c) 2003 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 4,270 subscribers worldwide.

This is a valid HTML 4.01 Transitional document

 

Return to top...