Wednesday, April 14, 2010

Detect Quoted Macro String

If you have a macro string like this:

%let keyword = "Google";

, you want to determine if this macro string is a quoted string. Below is a handy macro code that does that:


 %if  %qsubstr(&keyword, 1, 1) = %str(%") &
%qsubstr(&grp, %length(&grp), 1) = %str(%") %then
%do;
  %let is_a_quoted_string = Yes;
%end;