|
RATCLIFFE Technical Services Limited |
NOTE: |
|
Issue 2. March 2001 |
Hints, tips, and experience for SAS(r) users |
|
|
Welcome to the second issue of NOTE:. If you received issue 1 and have maintained your subscription, I'm glad you found the content interesting; if you're a new subscriber, I hope you find the content of this issue (and subsequent issues) to be of interest to you. If you like NOTE:, please encourage your colleagues, friends, and clients to subscribe; otherwise, please let me know what you'd like added or changed. The last couple of months have taught me a great deal about HTML (especially when used in emails). If I've not got it perfect yet, please let me know how the presentation (or content) could be improved. -Andrew |
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Moving binary data across platform. Are your platforms big-endian or little-endian? |
Around about this time last year I had a binary data file created on Sun Solaris (UNIX) that I needed to regularly read on Windows NT. The data file was created by a non-SAS software system and included some positive integer binary fields. I could read these using SAS software on Solaris and the PIB. informat. However, the data could not successfully be read on Windows NT because Windows NT uses a different representation of binary data to Solaris. As an example, I had a two byte unsigned field in the file containing 5; the PIB informat on Windows NT said the field contained 1280. The format of binary data on Windows is different to most flavours of UNIX. Solaris and many other UNIX platforms are known as "big-endian" systems; Windows and Digital UNIX platforms are "little-endian". The two types of platform store their binary data in a different order. Big-endian systems store their byte data left-to-right, so that 1 stored in a four byte field would be stored as 00 00 00 01. Little-endian systems store their byte data right-to-left, so that 1 stored in a four byte field would be stored as 01 00 00 00. Now you can begin to see the problem - the PIB informat on Windows NT said the field contained 16,777,216. The PIB informat is platform-dependant and will expect the data it is reading to be in the format supported by the platform. If you know that your data has come from a "foreign" platform, you can use an alternative informat. In my case, the S370FPIB informat did the trick. The following table summarises all the options. The "Sign?" column indicates whether the data to be read is signed or not.
Some of this information was obtained from SAS software V8 OnlineDoc. For the full text, find "byte ordering" in the Master Index, or search for "endian". |
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
No more accidental SHOUTING! |
It is my intention to focus on issues related to SAS software and its usage, but occasionally I will include something non-SAS if I believe that it is sufficient importance for the majority of readers. This particular tip relates to MS-Windows, but that doesn't imply that I'm assuming you all use MS-Windows. The next tip just might be for UNIX or for VMS or for MVS or for... Anyway, do you get tired of pressing the Caps Lock key by mistake? Well, reduce this error by turning on an option which will make a beep every time you press the Caps Lock. Go to the Control Panel, choose Accessibility Options, and then tick the Use ToggleKeys option on the Keyboard tab. Believe me, this little feature has saved me countless wrongly-capitalised keystrokes since it was pointed-out to me. I'm told it can be a little harder to find sometimes on Windows 98, but just search the help for "ToggleKeys". My thanks to Woody Leonhard for this tip. His e-newsletters on Microsoft topics are excellent. Catch them at www.woodyswatch.com. |
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The UK's independent SAS user group |
After the last issue of NOTE:, I had a number of questions from subscribers asking what VIEWS and VIEWS News are. Well, VIEWS is the UK's SAS(r) user group. Independent of SAS Institute, VIEWS is run by a committee of SAS partners and users. I am the incumbent chairman and co-editor of the quarterly VIEWS News newsletter. VIEWS organises a variety of SAS-related events and activities throughout the year. Events include an annual conference, plus days focused on individuals - typically Books By Users authors - and days focused on topics such as pharmaceuticals and data mining. This year's annual conference is likely to be a two-day, multi-stream event in London at the end of September. The VIEWS newsletter (VIEWS News) contains short, punchy hints and tips for SAS practitioners. It is printed and posted to UK-based VIEWS members on a quarterly basis. Back issues are available for download from the VIEWS web site at www.views-uk.org. The web site also contains an FAQ, a variety of papers and articles in its Resources section, and news on forthcoming VIEWS events and activities. VIEWS publishes a calendar each year that is sent free of charge to all members. Membership is free and is available to all UK-based SAS practitioners - just send a request to membership@views-uk.org. Include your postal address to get your free copies of VIEWS News, the annual calendar, and news of forthcoming events. It is important to stress that NOTE: is produced by myself and has no association with VIEWS (or VIEWS News). |
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
Coding style is a very personal thing and, as I mentioned in issue#1, will probably be specific to a given SAS site. However, I hope you find this series to be useful and stimulating. I welcome your comments... |
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
In respect of the first instance, it is not desirable to leave a module with a mixture of styles in it, so you have the choice of either changing everything to your own chosen style, or of making your changes and matching the existing style. You need to make a judgement about the amount of work involved in changing the existing code - are you just making a small change (in which case, do it in the existing style), or are you making wholesale changes (in which case, convert the lot to your new style). In the eventuality of an exceptional case where you believe it is necessary to deviate from the chosen coding standards (the second instance), make sure you understand the reason for the particular coding standard that you would wish to break. And if you feel you are truly justified in what you are doing, make sure you document what you have done and the reasons why you did it. |
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
The subject of comments is a big one. In this issue I'll focus on comments related to DO blocks since I talked about DO blocks in the last issue. In general, comments should inform. They serve very little purpose if they merely state things about the code that are already obvious to the casual observer. In addition to informing the reader about your intent and the reasons why you chose a particular coding solution, comments can be useful to aid with the layout and structure of coding. The layout and structure of your code helps you and others to comprehend it. One common aspect of layout and structure is indentation. I'll discuss indentation in greater detail in a future issue, but suffice it to say that most programmers indent lines of their code to indicate blocks and sub-blocks of code. The indentation is a great help in displaying the structure and flow of the code. I use paired comments with DO blocks to add to this. See the example below: if 1 eq 0 then do; /* Never true */ moon = 'cheese'; clouds = 'marshmallow'; end; /* Never true */ The DO and the END statements share the same comment. In the simple example above they don't add much to the understanding, but in complicated code with lots of sub-setted IFs and plenty of ELSEs to go with them, being able to match an END with a DO easily has great value. On a SELECT statement, I use them thus: select (switch); when (true) do; /* true */ ... end; /* true */ ... end; /* select switch */ And with a DO loop, thus: do ptr_digits = 1 to listlen(lDigits); ... end; /* do over digits */ |
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
If you like NOTE: you might like these too |
If you want to receive more information about SAS software in your inbox, you might like to take a look at Systems Seminar Consultants' web site. They offer The Missing Semicolon at www.sys-seminar.com/SASNewsletter.htm. It is a quarterly publication, emailed in PDF format. Subscription is free. I'm sure you're already aware of SAS Institute's technical and business newsletters at www.sas.com/subscriptions. If not, sign-up quickly! They're (bi)weekly HTML emails with links to articles on the SAS web site. If you find any others, please let me know so that I can pass-on the word. |
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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 these events, please let me know (I may be going too, it would be nice to meet), I'd be very grateful for any comments after the event. |
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
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 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 Ratcliffe is chairman of VIEWS (the UK's independent SAS user group). NOTE: is a production solely of RTSL and has no affiliation with VIEWS. |