Chapter Contents

Previous

Next
%VERIFY

%VERIFY



Returns the position of the first character unique to an expression

Type: Autocall macro
Requires: MAUTOSOURCE system option


Syntax
Details
Example
Testing for a Valid Fileref

Syntax

%VERIFY(source,excerpt)

source
is text or a text expression. This is the text 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.

Note:    Autocall macros are included in a library supplied by SAS Institute. This library may not be installed at your site or may 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 SAS Software Consultant. For more information, see Chapter 9 in SAS Macro Language: Reference.  [cautionend]


Details

%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

Example 1: Testing for a Valid Fileref

The ISNAME macro checks a string to see if 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$)

Executing this program writes this 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 "$".


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.