sasname.sas
%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;