BookmarkSubscribeRSS Feed
Calcite | Level 5


I have a question when do I have to use double quotation marks in where statement.


In this problem, it says that I have to use single quotation marks.


But in this problem, I can use double quotation marks.

What is the difference between both situations?

Thank you !

Super User Tom
Super User

SAS itself does not care if you use single quote characters (also called apostrophes)  or double quote characters on the outside to create string literals.


And it does not matter whether the string literals appear in a WHERE clause or any other place where a string literal can be used.


They suggested using single quotes in the first example because of the % characters in the sting.  The % and & characters are important to the MACRO PROCESSOR.   The macro processor is a pre-processor that analyses the code and can be used to generate different SAS code based on the macro statements, macro variable references and macro call it sees in the text of the code.  The macro processor uses % as the trigger to look for a macro statement, or macro function call or a macro call.  It uses & as the trigger to start the evaluation of macro variable references.


But the macro processor will ignore string literals that are bounded by single quotes.  So when you use single quotes to enclose the string literal the macro processor will NOT see the string %preserve as an attempt to call a macro named preserve.


The second example does not have that problem because there is no way that the macro processor will interpret that % sign as the start of macro code since it is immediately followed by the quote. So in the second situation you can use either double quote characters, "YOSE%", or single quote characters, 'YOSE%', since there is no need to hide that string from the macro processor.



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg



Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 2 in conversation