MVALID Function

Checks the validity of a character string for use as a SAS member name.

Category: Character

Syntax

Required Arguments

libname

specifies a character constant, variable, or expression that associates a SAS library with a libref. Leading and trailing blanks are ignored.

string

specifies a character constant, variable, or expression that is checked to determine whether its value can be used as a SAS member name. Leading and trailing blanks are ignored.

memtype

specifies a character constant, variable, or expression that is the member type of the member name that you are using. Leading and trailing blanks are ignored. The value of memtype is not validated. The following member types are available:

ACCESS specifies access descriptor files that are created by SAS/ACCESS.
CATALOG specifies SAS catalogs.
DATA specifies SAS data files.
FDB specifies a financial database.
ITEMSTOR specifies a SAS data set that consists of pieces of information that can be accessed independently. The SAS Registry is an example of an item store.
MDDB specifies a multidimensional database.
PROGRAM specifies stored compiled SAS programs.
VIEW specifies SAS views.

Optional Argument

validmemname

specifies a character constant, variable, or expression. The values for validmemname can be uppercase or lowercase. Leading and trailing blanks are ignored. The following list contains the values that you can use with validmemname:

COMPAT

COMPATIBLE

determines that string is a valid SAS member name when all three of the following conditions are true:

  • The string argument begins with an English letter or an underscore.
  • All subsequent characters are English letters, underscores, or digits.
  • The length of string is 32 or fewer alphanumeric characters.

EXTEND

determines that string is a valid SAS member name when all of the following conditions are true:

  • The length of string is 32 or fewer bytes.
  • The string argument does not contain the characters / \ * ? " < > | : –
    Note: The SPD Engine additionally does not allow '$' as the first character. It also does not allow a period (.) in the member name.
  • The string argument does not contain null bytes.
  • The string argument does not begin with a blank or period (.).
  • The string argument contains at least one character. A name that consists of all blanks is not valid.
Default VALIDMEMNAME= is set to COMPAT.
Note If no value is specified, the MVALUE function determines that string is a valid SAS member name based on the value of the VALIDMEMNAME= system option.

Details

The Basics

The MVALID function checks the value of string to determine whether it can be used as a SAS member name.
The MVALID function returns a value of 1 if string can be used as a SAS member name, and a value of 0 if string cannot be used as a SAS member name.
MVALID returns a missing value if one of the following conditions is true:
  • The libname argument is not an assigned libref.
  • The memtype argument is longer than nine characters.
  • The validmemname argument does not have one of the following values: COMPATIBLE, COMPAT, or EXTEND, regardless of whether the value is uppercase or lowercase.

Requirements for Validation of a SAS Member Name

The string argument is evaluated to determine whether it is a valid SAS member name. An engine name with its associated library, as well as member type, affect the validation of string. Of the member types, only DATA, ITEMSTOR, and VIEW allow names with extended characters. When string is evaluated, the EXTEND value of the optional validmemname argument is taken into account. Not all engines support validmemname processing. For the engines that do not, string is validated based on the rules for that engine.
The following example shows you how to use the MVALID function to determine whether string is a valid SAS member name, based on engine name, DATA member type, and the EXTEND value for validmemname:
libname V9eng V9 'mypath';
data _null_;
   rc=MVALID('V9eng', 'my name', 'data', 'extend');
   put rc=;
run;
The following items apply to the preceding example:
  • The example returns a value of 1, indicating that 'my name' is a valid member name for the V9 engine when member type equals DATA and validmemname equals EXTEND.
  • If you use the V6 engine in the example, the program returns a value of 0, indicating that 'my name' is not valid when member type equals DATA and validmemname equals EXTEND. The V6 engine does not support validmemname processing.
In the following example, CATALOG is used instead of DATA for member type:
libname V9eng V9 'mypath';
data _null_;
   rc=MVALID('V9eng', 'my name', 'catalog', 'extend');
   put rc=;
run;
The following items apply to the preceding example:
  • If you use CATALOG in the example instead of DATA, the program returns a value of 0, indicating that 'my name' is not valid when member type equals CATALOG and validmemname equals EXTEND. The member type CATALOG does not support extended names, and therefore the EXTEND value for validmemname is not valid.
  • If you use COMPAT in the example instead of EXTEND, the program returns a value of 0, indicating that 'my name' is not valid when member type equals CATALOG and validmemname equals COMPAT. The COMPAT value of validmemname does not allow spaces in member names.