/*----- * group: Macro programming * purpose: Determine if a string is a valid SAS name * notes: Based on David L. Ward's %SASNAME posted to SAS-L April 11, 2002. Rewritten using verify(). */ %macro sasname(name); %* Richard A. DeVenezia; %* 5/20/02; %local MAXLEN EMIT V1 V2; %if &sysver < 7 %then %let MAXLEN = 8; %else %let MAXLEN = 32; %let NAME = %upcase(&NAME); %if %length(&NAME) > &MAXLEN %then %let EMIT=0; %else %do; %let V1 = %sysfunc (verify (&NAME,_ABCDEFGHIJKLMNOPQRSTUVWXYZ)); %let V2 = %sysfunc (verify (&NAME,_ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789)); %if &V1 = 0 %then %let EMIT = 1; %* NAME contained only _A-Z; %else %if &V1 = 1 %then %let EMIT = 0; %* NAME did not start with _A-Z; %else %if &V2 = 0 %then %let EMIT = 1; %* NAME started with _A-Z with remainder containing only _A-Z0-9; %else %let EMIT = 0; %* NAME contained something other than _A-Z _A-Z0-9 ...; %end; &EMIT %mend sasname;