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.