Variable Names Can Be More Than One Word With Blanks Between the Words.
Rules for Words and Names in the SAS Language
Names in the SAS Linguistic communication
A SAS proper noun is a proper name token that represents
-
variables
-
SAS data sets
-
formats or informats
-
SAS procedures
-
options
-
arrays
-
argument labels
-
SAS macros or macro variables
-
SAS catalog entries
-
librefs or filerefs
-
component objects
There are two types of names in SAS:
-
names of elements of the SAS language
-
names supplied past SAS users
Rules for Virtually SAS Names
Notation: The rules are more flexible for SAS variable names than for other language elements. Meet Rules for SAS Variable Names.
-
The length of a SAS name depends on the element it is assigned to. Many SAS names can be 32 characters long; others have a maximum length of 8.
-
The first grapheme must be an English alphabetic character (A, B, C, . . ., Z) or underscore (_). Subsequent characters can be messages, numeric digits (0, 1, . . ., 9), or underscores.
-
Y'all tin can employ upper or lowercase letters.
-
Blanks cannot announced in SAS names.
-
Special characters, except for the underscore, are not immune. In filerefs merely, you tin can use the dollar sign ($), pound sign (#), and at sign (@).
-
SAS reserves a few names for automatic variables and variable lists, SAS data sets, and librefs.
-
When creating variables, practise non employ the names of special SAS automated variables (for example, _N_ and _ERROR_) or special variable list names (for example, _CHARACTER_, _NUMERIC_, and _ALL_).
-
When associating a libref with a SAS library, do not use these:
SASHELP
SASMSG
SASUSER
WORK
-
When y'all create SAS data sets, practice not use these names:
-
-
When assigning a fileref to an external file, do non employ the filename SASCAT.
-
When you create a macro variable, do non use names that begin with SYS.
SAS Language Element | Maximum Length |
---|---|
Arrays | 32 |
CALL routines | 16 |
Itemize entries | 32 |
Information pace argument labels | 32 |
DATA step variable labels | 256 |
DATA step variables | 32 |
DATA step windows | 32 |
Engines | 8 |
Filerefs | eight |
Formats, character | 31 |
Formats, numeric | 32 |
Functions | 16 |
Generation data sets | 28 |
Informats, character | xxx |
Informats, numeric | 31 |
Librefs | 8 |
Macro variables | 32 |
Macro windows | 32 |
Macros | 32 |
Members of SAS libraries (SAS data sets, SAS views, catalogs, indexes) except for generation data sets | 32 |
Passwords | viii |
Procedure names (first viii characters must exist unique, and cannot begin with "SAS") | 16 |
SCL variables | 32 |
Rules for SAS Variable Names
The rules for SAS variable names take expanded to provide more functionality. The setting of the VALIDVARNAME= system option determines what rules apply to the variables that you can create and process in your SAS session likewise every bit to variables that you desire to read from existing data sets. The VALIDVARNAME= option has three settings (V7, UPCASE, and Whatever), each with varying degrees of flexibility for variable names:
- V7
-
is the default setting.
Variable proper noun rules are as follows:
-
SAS variable names can be up to 32 characters in length.
-
The outset character must begin with an English language letter or an underscore. Subsequent characters can be English language messages, numeric digits, or underscores.
-
A variable name cannot comprise blanks.
-
A variable name cannot contain any special characters other than the underscore.
-
A variable name tin contain mixed example. Mixed case is remembered and used for presentation purposes only. (SAS stores the instance used in the starting time reference to a variable.) When SAS processes variable names, however, information technology internally uppercases them. You cannot, therefore, utilise the aforementioned letters with unlike combinations of lowercase and uppercase to represent different variables. For example, true cat, Cat, and CAT all represent the aforementioned variable.
-
You do not assign the names of special SAS automated variables (such equally _N_ and _ERROR_) or variable list names (such as _NUMERIC_, _CHARACTER_, and _ALL_) to variables.
-
- UPCASE
-
is the same as V7, except that variable names are uppercased, as in before versions of SAS.
- Any
-
-
SAS variable names can be up to 32 characters in length.
-
The name can contain special and multi-byte characters not to exceed 32 bytes.
-
The name cannot comprise whatsoever null bytes.
-
A name can contain blanks. The leading blanks are preserved, simply the trailing blanks are ignored.
-
A name must contain at least one character. A name with all blanks is not permitted.
-
The proper noun can start with or incorporate any characters, including blanks.
Note: If you use any characters other than the ones that are valid when the VALIDVARNAME system option is set to V7 (messages of the Latin alphabet, numerals, or underscores), then you must express the variable name as a name literal and yous must set VALIDVARNAME=ANY.
If you use either the per centum sign (%) or the ampersand (&), then you must use single quotation marks in the name literal in gild to avoid interaction with the SAS Macro Facility. See SAS Name Literals.
-
A variable proper name tin can contain mixed-case messages. Mixed-instance letters are stored and used for presentation purposes only. (SAS stores the example that is used in the start reference to a variable.) When SAS processes variable names, however, it internally uppercases them. Therefore, you cannot utilize the same letters with different combinations of lowercase and uppercase to represent different variables. For example, true cat, Cat, and CAT all represent the same variable.
Warning: The intent of the VALIDVARNAME=ANY organisation option is to enable compatibility with other DBMS variable (column) naming conventions, such as allowing embedded blanks and national characters. Throughout SAS, using the name literal syntax with variable names that exceed the 32-byte limit or take excessive embedded quotation marks might cause unexpected results. -
Definition of SAS Proper noun Literals
A SAS name literal is a name token that is expressed as a cord within quotation marks, followed by the upper- or lowercase letter n. Name literals enable yous to use special characters (including blanks) that are not otherwise allowed in SAS names when you specify a SAS data prepare or a variable. Blanks between the closing quotation marker and the north are not valid when you lot specify a name literal. When the name literal of a information set up or variable contains any characters that are not allowed when VALIDVARNAME=V7, and then y'all must set the VALIDVARNAME= system choice to Any. Annotation that even if you prepare the arrangement choice to ANY, the V6 engine does not support names that accept intervening blanks.
Name literals are especially useful for expressing DBMS cavalcade and table names that contain special characters.
The post-obit is an example of a VAR statement and a proper noun literal:
var 'a b'n;
The following is an example of a VAR argument with variables A and B:
var a b;
Important Restrictions
-
You can use a proper noun literal only for variables, statement labels, and DBMS column and tabular array names.
-
When the name literal of a variable or DBMS column contains any characters that are not allowed when VALIDVARNAME=V7, then you must ready the system option VALIDVARNAME=ANY.
Note: For more details about the VALIDVARNAME=Any organization pick, see SAS Language Reference: Dictionary.
-
If you utilize either the percent sign (%) or the ampersand (&), and so y'all must use unmarried quotation marks in the name literal in order to avoid interaction with the SAS Macro Facility.
-
When the name literal of a DBMS table or column contains whatsoever characters that are not valid for SAS rules, then you lot might demand to specify a SAS/ACCESS LIBNAME statement option.
Note: For more details and examples most the SAS/ACCESS LIBNAME statement and about using DBMS table and column names that practise not accommodate to SAS naming conventions, see SAS/ACCESS for Relational Databases: Reference.
-
In a quoted string, SAS preserves and uses leading blanks, but SAS ignores and trims trailing blanks.
Avoiding Errors When Using Proper noun Literals
For data on how to avoid creating name literals in mistake, see Fugitive a Common Error with Constants.
Examples
Examples of SAS name literals are
-
input 'Bob''s Asset Number'n;
-
input "Bob's Asset Number"n;
-
libname foo SAS/Admission-engine-name SAS/Access-engine-connection-options; information foo.'My Table'n;
-
input 'Amount Budgeted'north 'Amount Spent'due north 'Corporeality Difference'n;
Copyright © 2010 past SAS Institute Inc., Cary, NC, The states. All rights reserved.
riverafiresom1957.blogspot.com
Source: https://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/a000998953.htm
0 Response to "Variable Names Can Be More Than One Word With Blanks Between the Words."
Post a Comment