%VERIFY Autocall Macro

Returns the position of the first character unique to an expression.
Type: Autocall macro
Requirement: MAUTOSOURCE system option

Syntax

%VERIFY(source, excerpt)

Required Arguments

source
is text or a text expression that you want to examine for characters that do not exist in excerpt.
excerpt
is text or a text expression. This is the text that defines the set of characters that %VERIFY uses to examine source.

Details

Note: Autocall macros are included in a library supplied by SAS. This library might not be installed at your site or might be a site-specific version. If you cannot access this macro or if you want to find out if it is a site-specific version, see your on-site SAS support personnel. For more information, see Storing and Reusing Macros.
%VERIFY returns the position of the first character in source that is not also present in excerpt. If all characters in source are present in excerpt, %VERIFY returns 0.

Example: Testing for a Valid Fileref

The ISNAME macro checks a string to verify that it is a valid fileref and prints a message in the SAS log that explains why a string is or is not valid.
%macro isname(name);
    %let name=%upcase(&name);
    %if %length(&name)>8 %then
       %put &name: The fileref must be 8 characters or less.;
    %else %do;
       %let first=ABCDEFGHIJKLMNOPQRSTUVWXYZ_;
       %let all=&first.1234567890;
       %let chk_1st=%verify(%substr(&name,1,1),&first);
       %let chk_rest=%verify(&name,&all);
       %if &chk_rest>0 %then
          %put &name: The fileref cannot contain
              "%substr(&name,&chk_rest,1)".;
       %if &chk_1st>0 %then
          %put &name: The first character cannot be
              "%substr(&name,1,1)".;
       %if (&chk_1st or &chk_rest)=0  %then
          %put &name is a valid fileref.;
    %end;
 %mend isname;
%isname(file1)
%isname(1file)
%isname(filename1)
%isname(file$)
When this program executes, the following is written to the SAS log:
FILE1 is a valid fileref.
1FILE: The first character cannot be "1".
FILENAME1: The fileref must be 8 characters or less.
FILE$: The fileref cannot contain "$".