Functions and CALL Routines |
Category: | Character |
Restriction: | I18N Level 2 |
Syntax | |
Arguments | |
Details | |
Length of Returned Variable | |
The Basics | |
Examples | |
See Also |
Syntax |
NLITERAL(string) |
specifies a character constant, variable, or expression that is to be converted to a SAS name literal.
Tip: | Enclose a literal string of characters in quotation marks. |
Restriction: | If the string is a valid SAS variable name, it is not changed. |
Details |
In a DATA step, if the NLITERAL function returns a value to a variable that has not previously been assigned a length, then the variable is given a length of 200 bytes.
String will be converted to a name literal, unless it qualifies under the default rules for a SAS variable name. These default rules are in effect when the SAS system option VALIDVARNAME=V7:
String qualifies as a SAS variable name, when all of these rules are true.The NLITERAL function encloses the value of string in single or double quotation marks, based on the contents of string.
If insufficient space is available for the resulting n-literal, NLITERAL returns a blank string, prints an error message, and sets _ERROR_ to 1.
Examples |
This example demonstrates multiple uses of NLITERAL.
data test; input string $32.; length result $ 67; result = nliteral(string); datalines; abc_123 This and That cats & dogs Company's profits (%) "Double Quotes" 'Single Quotes' ; proc print; title 'Strings Converted to N-Literals or Returned Unchanged'; run;
Converting Strings to Name Literals with NLITERAL
Strings Converted to N-Literals or Returned Unchanged 1 Obs string result 1 abc_123 abc_123 2 This and That "This and That"N 3 cats & dogs 'cats & dogs'N 4 Company's profits (%) 'Company''s profits (%)'N 5 "Double Quotes" '"Double Quotes"'N 6 'Single Quotes' "'Single Quotes'"N
See Also |
| |||||||
| |||||||
Rules for Words and Names in the SAS Language in SAS Language Reference: Concepts |
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.