LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (October 1996, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 18 Oct 1996 11:12:06 -0400
Reply-To:     Laurie Fleming <lfleming@ACTRIX.GEN.NZ>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         Laurie Fleming <lfleming@ACTRIX.GEN.NZ>
Organization: Actrix Networks Limited
Subject:      Here's a handy (macro) thingy...

Straight SAS code won't allow a '%if' command, because it has to be placed inside a macro, whereas other macro commands can be typed in directly (command line, between procs et al).

However, sometimes I have to do a conditional macro statement, and here's one way of doing it. I commonly want to right-justify and zero fill a pseudo-numeric macro value so I can do valid comparisons with other values. Assume a value in 'i' of 53, and a required value of 00053:

%let i = %substr(0000&i, %length(&i), 5);

The first parameter resolves to 000053, the second to 2 (the length of the text value '53', and the result: 53. If i = 5, then the first parameter is 00005, the second 1, and the result 00005.

It may not be that important, but if there were an obfuscated SAS competition, this would be my one-liner. (-8

Laurie Fleming | What do you get when you | (+64 4) 479-1589 4 Kenya St | cross Lee Iacocca and a | (+64 21) 688-140 Ngaio | vampire? | lfleming@actrix.gen.nz Wellington 6004 | | flemingl@ho.acc.org.nz New Zealand | Autoexec bat. |


Back to: Top of message | Previous page | Main SAS-L page