VALIDVARNAME= SAS System Option

Controls the type of SAS variable names that can be used or created during a SAS session.

Valid in: configuration file, SAS invocation, OPTIONS statement, SAS System Options window
Category: Files: SAS Files
Default: V7
See: Introduction to SAS/ACCESS Naming, VALIDMEMNAME= system option

Syntax

VALIDVARNAME=V6 | V7 | UPCASE | ANY

Required Arguments

VALIDVARNAME=V6

indicates that a DBMS column name is changed to a valid SAS name, following these rules:

  • Up to eight alphanumeric characters are allowed. Names that are longer than eight characters are truncated. If required, numbers are appended to the ends of the truncated names to make them unique.
  • Mixed-case characters are converted to uppercase.
  • Special characters are not allowed.
Note: The primary reason for using this value is for existing SAS code that references variables that use older naming rules.

VALIDVARNAME=V7

indicates that a DBMS column name is changed to a valid SAS name, following these rules. This is the default value for SAS 7 and later.

  • Up to 32 mixed-case alphanumeric characters are allowed.
  • Names must begin with an alphabetic character or an underscore.
  • Invalid characters are changed to underscores.
  • Any column name that is not unique when it is normalized is made unique by appending a counter (0, 1, 2, and so on) to the name.

VALIDVARNAME=UPCASE

indicates that a DBMS column name is changed to a valid SAS name as described in VALIDVARNAME=V7 except that variable names are in uppercase.

VALIDVARNAME=ANY

allows any characters in DBMS column names to appear as valid characters in SAS variable names. Symbols, such as the equal sign (=) and the asterisk (*), must be contained in a 'variable-name'n construct. You must use ANY whenever you want to read DBMS column names that do not follow the SAS naming conventions.

Up to 32 characters are allowed in a column name.

Any column name that is not unique when it is normalized is made unique by appending a count (0, 1, 2, and so on).

Details

The VALIDVARNAME= system option is supported for all DBMSs that support the SQL pass-through facility. You can set this option on start-up or in an OPTIONS statement, and the option value is used in the call to the SQL procedure. Alternatively, you can specify the VALIDVARNAME= option in the CONNECT statement.

The VALIDVARNAME= system option is often used with the VALIDMEMNAME= system option. For more information, see VALIDMEMNAME= System Option in SAS System Options: Reference.

Examples

Example 1: Rename Columns during View Creation

This example shows how the SQL pass-through facility works with VALIDVARNAME=V6.

options validvarname=v6;
proc sql;
   connect to hadoop (user=myusr1 pass=mypwd1);
   create view myview as
     select amount_b, amount_s
       from connection to hadoop
         (select "Amount Budgeted$", "Amount Spent$"
            from mytable);
quit;
proc contents data=myview;
run;

Output from this example would show that "Amount Budgeted$" becomes AMOUNT_B and "Amount Spent$" becomes AMOUNT_S.

Example 2: Pass VALIDVARNAME= as a Connection Option

This example shows how you can pass VALIDVARNAME= as a connection option in the CONNECT statement in the SQL procedure.

proc sql;
    drop view work.TLV1;
    connect to hadoop ( validvarname=v7 server="myserver" port=5433
user=myuserid password=mypwd database=test);
      exec("drop table vartb") by hadoop;
      exec("create table vartb ( c1234567890 int,
c123456789012345678 float ) ") by hadoop;
      exec("insert into vartb values (123, 3.14159)") by hadoop;

      create view tlv1 as
        select * from connection to hadoop (select * from vartb);
quit;
Last updated: February 3, 2026