f



Re: if str_mo not in ('','.') and str_da not in ('','.') and str_ yy not in ('','.') Any shorter ? #3

> From: Igor Kurbeko [mailto:ikurbeko@ATHEROGENICS.COM]
> I'm just curious if it ever dawned on anybody
> how to abbreviate this line :
>
> if  str_mo not in ('','.')
> and str_da not in ('','.')
> and str_yy not in ('','.')

%*in autoexec:;
%Let Blank   = Blank;
%Let Invalid = Invalid;

%*in aFormat;
PROC Format;
value $StrValu %*somevalues = 'ok';
                   '','.' = "&Blank."
               %*  other  = "&Invalid.";
                ;

%*in Program;
if put(Str_Mo,$StrValu.) not eq "&Blank."

use an array and a flag:
array Str (*) $ 4 Str_Month
                  Str_Day
                  Str_YY;
drop I;
Flag   = 0;
do   I = 1 to dim(Str); Flag = Flag or
                        put(Str(I),$StrValu.) not eq "&Blank."
                        end;
if Flag then ...

shorter?
or conceptually shorter
or conceptually simpler

the above reduces three occurences of '','.'
to one occurence in proc Format

if any changes need to be made,
like adding '..',
then one change affects usage for all three variables.

Ron Fehd  the macro maven  CDC Atlanta GA USA RJF2@cdc.gov

Repetition obfuscates!
Repetition reduction enhances elegance!
Repetition reduction furthers finesse!

see also:
NESUG 2001
Adv Tutor   pg 53
%INVALID: a data review macro
using proc FORMAT option other=INVALID to identify and list outliers
http://www.pace.edu/nesug/proceedings/nesug01/at/At1008.pdf
0
rjf2 (3342)
10/23/2003 12:49:57 PM
comp.soft-sys.sas 142828 articles. 3 followers. Post Follow

0 Replies
957 Views

Similar Articles

[PageSpeed] 6

Reply: