Attempting to include examples of both single and double quotation marks inside a quoted string causes problems with early termination of the quoted string, e.g.:
title "Presenting: The 'right' way to use "quotes"!" ; proc print data = sashelp.class (obs = 1 ) ; run ;
generates the following in the LOG:
3 title "Presenting: The 'right' way to use "quotes"!" ; ------------------------------------- 49 WARNING: The TITLE statement is ambiguous due to invalid options or unquoted text. NOTE 49-169: The meaning of an identifier after a quoted string may change in a future SAS release. Inserting white space between a quoted string and the succeeding identifier is recommended.
the underlined section indication where the system determines the quoted string appears.
Attempting to store the text in a macro variable:
%let titletext = The 'right' way to use "quotes"! ; title "Presenting: &titletext" ; proc print data = sashelp.class (obs = 1 ) ; run ;
generates the same error as the macro variable is resolved for the stored text at Compile Time.
In order to mask the quotation marks, the %BQUOTE Macro Quoting function can be used to remove the special meaning of the characters at Execution Time;
%let titletext = %bquote(The 'right' way to use "quotes"!) ; %put _user_ ; %put &titletext ;
Using the %put _user_ ;
statement renders the value along with the Macro Quoting. Writing the value with the %put &titletext ;
statement renders the stored value in the LOG and unquotes the value for printing.The LOG shows the values:
GLOBAL TITLETEXT □The □right□ way to use □quotes□!□ The 'right' way to use "quotes"!
Using the Macro Quoted value within the quoted string
title "Presenting: &titletext" ; proc print data = sashelp.class (obs = 1 ) ; run ;
allows for the masked characters to be resolved only for printing, without generating the syntax error at Compile Time:
Presenting: The 'right' way to use "quotes"! Obs Name Sex Age Height Weight 1 Alfred M 14 69 112.5