DATA Step, Macro, Functions and more

Closed: Using and escaping special characters within SAS?

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
Posts: 8,744

Re: Using and escaping special characters within SAS?

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:

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.

Posts: 32

Re: Using and escaping special characters within 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
  • 2 in conversation