DATA Step, Macro, Functions and more

Closed: Using and escaping special characters within SAS?

Reply
Contributor
Posts: 32

Closed: Using and escaping special characters within SAS?

In doing some ETL development I am finding that SAS isn't allowing me to use some special characters (e.g., parentheses and single quotes) in some places (e.g., file descriptions, file names).

Is there a complete list of non-usable special characters and what/if any escapes there are for their use.

(Please inform me if this is posted in the wrong forum.)

Please let me know if more info is required.

Thanks Thanks, but I have answered this.

Message was edited by: veblen
SAS Super FREQ
Posts: 8,864

Re: Using and escaping special characters within SAS?

Hi:
SAS file references and file names have strict rules about what a valid SAS name can be. For example, this is a valid column or variable name: AGE_GROUP_1 however 1_AGE_GROUP is an invalid name because it starts with a number and SAS names cannot start with numbers. Valid SAS names can ONLY contain numbers, letters and underscores (spaces not allowed) and must start with a letter or underscore. So this would also be a valid variable or column name: _1_AGE_GROUP.

However, due to the fact that some systems do allow special characters or spaces in a name, for example, SAS also allows you to use "name literals" tokens or strings to reference variables. Some references are:
http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000998953.htm
http://support.sas.com/documentation/cdl/en/acreldb/63647/HTML/default/viewer.htm#a001392879.htm

For example, as a name literal, it shows in the documentation that you could read in a column or variable with a name of [pre] '$ Amount Budgeted'n or 'Amount Spent'n [/pre] Note that in this syntax construction the whole string is quoted and is immediately followed by an n, which indicates that the string is a name literal.

You might want to open a track with Tech Support for more thorough help on this issue, they can look at all your code and your operating system configuration and make specific recommendations.

cynthia
Contributor
Posts: 32

Re: Using and escaping special characters within SAS?

Posted in reply to Cynthia_sas
My apologies for the slow response, but THANKS for the assistance Cynthia.

Your advice and the links came in handy and it is highly appreciated.
Ask a Question
Discussion stats
  • 2 replies
  • 185 views
  • 0 likes
  • 2 in conversation